Skip to content

Commit 6bf4213

Browse files
0xMimirdannywillems
authored andcommitted
Added tests
1 parent 64c4bb2 commit 6bf4213

File tree

1 file changed

+134
-1
lines changed

1 file changed

+134
-1
lines changed

node/native/src/graphql/zkapp.rs

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ impl TryFrom<InputGraphQLAuthorization> for MinaBaseControlStableV2 {
324324
)?;
325325
Ok(MinaBaseControlStableV2::Proof(Box::new(proof)))
326326
}
327-
// Handle no auth case
328327
(None, None) => Ok(MinaBaseControlStableV2::NoneGiven),
329328
_ => Err(ConversionError::Custom(
330329
"Either signature or proof must be provided, but not both".into(),
@@ -1568,6 +1567,15 @@ mod test {
15681567
assert_eq!(mina_empty_memo.to_base58check(), expected);
15691568
}
15701569

1570+
#[test]
1571+
fn test_parse_zkap() {
1572+
let input = create_input_graphql_zkapp_bug_1464();
1573+
let _converted: MinaBaseUserCommandStableV2 = input
1574+
.zkapp_command
1575+
.try_into()
1576+
.expect("Failed to parse input");
1577+
}
1578+
15711579
#[test]
15721580
fn test_zkapp_from_input() {
15731581
let bytes = include_bytes!("../../../../tests/files/zkapps/valid_zkapp.bin");
@@ -1615,6 +1623,15 @@ mod test {
16151623
};
16161624
let converted: Result<MinaBaseControlStableV2, _> = proof.try_into();
16171625
assert!(converted.is_ok());
1626+
1627+
let proof = InputGraphQLAuthorization {
1628+
signature: None,
1629+
proof: None,
1630+
};
1631+
let converted: MinaBaseControlStableV2 =
1632+
proof.try_into().expect("Error parsing None given auth");
1633+
1634+
assert_eq!(converted, MinaBaseControlStableV2::NoneGiven);
16181635
}
16191636

16201637
fn create_input_graphql_zkapp() -> InputGraphQLZkapp {
@@ -1841,6 +1858,122 @@ mod test {
18411858
}
18421859
}
18431860

1861+
fn create_input_graphql_zkapp_bug_1464() -> InputGraphQLZkapp {
1862+
InputGraphQLZkapp {
1863+
zkapp_command: InputGraphQLZkappCommand {
1864+
memo: Some("E4YdMZb5VHHE51HPFPs1zUHnyus1q7RW61tWq1F4FNYrp5FKtKZMh".to_string()),
1865+
fee_payer: InputGraphQLFeePayer {
1866+
body: InputGraphQLFeePayerBody {
1867+
public_key: "B62qmGcEhZsZ2EMh2EzRXDJEmaD9PUJcW5xdNq2im2xNVuX2bsEPjoj".to_string(),
1868+
fee: "200000000".to_string(),
1869+
valid_until: None,
1870+
nonce: "250".to_string(),
1871+
},
1872+
authorization: "7mXMa44TWfDGtQmsfGtkRogZVzGVYqosP6qkXCBApsjoZ2ye2Y5AL2VWzp7m5CxkTjZhcoqtDVJkiQRm38tAmQdhpTTsSEr6".to_string(),
1873+
},
1874+
account_updates: vec![
1875+
InputGraphQLAccountUpdate {
1876+
body: InputGraphQLAccountUpdateBody {
1877+
call_depth: 0,
1878+
public_key: "B62qmGcEhZsZ2EMh2EzRXDJEmaD9PUJcW5xdNq2im2xNVuX2bsEPjoj".to_string(),
1879+
token_id: "wSHV2S4qX9jFsLjQo8r1BsMLH2ZRKsZx6EJd1sbozGPieEC4Jf".to_string(),
1880+
update: InputGraphQLAccountUpdateUpdate {
1881+
app_state: vec![
1882+
None,
1883+
None,
1884+
None,
1885+
None,
1886+
None,
1887+
None,
1888+
None,
1889+
None,
1890+
],
1891+
delegate: None,
1892+
verification_key: None,
1893+
permissions: None,
1894+
zkapp_uri: None,
1895+
token_symbol: None,
1896+
timing: None,
1897+
voting_for: None,
1898+
},
1899+
balance_change: InputGraphQLBalanceChange {
1900+
magnitude: "0".to_string(),
1901+
sgn: "Positive".to_string(),
1902+
},
1903+
increment_nonce: false,
1904+
events: vec![vec![
1905+
"852".to_owned(),
1906+
"993".to_owned(),
1907+
"540".to_owned(),
1908+
"951".to_owned(),
1909+
"340".to_owned()
1910+
]],
1911+
actions: vec![],
1912+
call_data: "0".to_string(),
1913+
preconditions: InputGraphQLPreconditions {
1914+
network: InputGraphQLPreconditionsNetwork {
1915+
snarked_ledger_hash: None,
1916+
blockchain_length: None,
1917+
min_window_density: None,
1918+
total_currency: None,
1919+
global_slot_since_genesis: None,
1920+
staking_epoch_data: InputGraphQLPreconditionsNetworkEpochData {
1921+
ledger: InputGraphQLPreconditionsNetworkLedger {
1922+
hash: None,
1923+
total_currency: None,
1924+
},
1925+
seed: None,
1926+
start_checkpoint: None,
1927+
lock_checkpoint: None,
1928+
epoch_length: None,
1929+
},
1930+
next_epoch_data: InputGraphQLPreconditionsNetworkEpochData {
1931+
ledger: InputGraphQLPreconditionsNetworkLedger {
1932+
hash: None,
1933+
total_currency: None,
1934+
},
1935+
seed: None,
1936+
start_checkpoint: None,
1937+
lock_checkpoint: None,
1938+
epoch_length: None,
1939+
},
1940+
},
1941+
account: InputGraphQLPreconditionsAccount {
1942+
balance: None,
1943+
nonce: None,
1944+
receipt_chain_hash: None,
1945+
delegate: None,
1946+
state: vec![
1947+
None, None, None, None, None, None, None, None
1948+
],
1949+
action_state: None,
1950+
proved_state: None,
1951+
is_new: None,
1952+
},
1953+
valid_while: None,
1954+
},
1955+
use_full_commitment: false,
1956+
implicit_account_creation_fee: false,
1957+
may_use_token: InputGraphQLMayUseToken {
1958+
parents_own_token: false,
1959+
inherit_from_parent: false,
1960+
},
1961+
authorization_kind: InputGraphQLAuthorizationKind {
1962+
is_signed: false,
1963+
is_proved: false,
1964+
verification_key_hash: Some("3392518251768960475377392625298437850623664973002200885669375116181514017494".parse().unwrap()),
1965+
},
1966+
},
1967+
authorization: InputGraphQLAuthorization {
1968+
proof: None,
1969+
signature: None
1970+
},
1971+
},
1972+
],
1973+
},
1974+
}
1975+
}
1976+
18441977
#[test]
18451978
pub fn test_bigint_to_decimal() {
18461979
let bigint = BigInt::from_decimal("1").unwrap();

0 commit comments

Comments
 (0)