Skip to content

Commit b9ae868

Browse files
committed
Reworks and improves test_wrapper_unknown_address
1 parent aaa2149 commit b9ae868

File tree

1 file changed

+20
-34
lines changed

1 file changed

+20
-34
lines changed

crates/node/src/shell/process_proposal.rs

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ mod test_process_proposal {
949949
// FIXME: need a test in finalize bloc kfor malleability of an inner tx doen
950950
// by the wrapper signer (check both one that fails because of signature and
951951
// one that fails because of indirect inclusion in tx data), this does not
952-
// need to be proptest
952+
// need to be proptest. will probably need soe more wasm for tests
953953
fn test_wrapper_bad_signature() {
954954
let (shell, _recv, _, _) = test_utils::setup_at_height(3u64);
955955

@@ -994,24 +994,29 @@ mod test_process_proposal {
994994
assert!(result.is_ok());
995995
}
996996

997-
/// Test that if the account submitting the tx is not known and the fee is
998-
/// non-zero, [`process_proposal`] rejects that block
999-
// FIXME: what's the putpose of this test? It's the same as the one that
1000-
// follows, unless we try to change the fees here to 0
997+
/// Test that an implicit account does not need to reveal the pk for fee
998+
/// payment
1001999
#[test]
10021000
fn test_wrapper_unknown_address() {
10031001
let (mut shell, _recv, _, _) = test_utils::setup_at_height(3u64);
10041002
let keypair = gen_keypair();
1005-
// reduce address balance to match the 100 token min fee
1003+
let address = Address::from(&keypair.ref_to());
10061004
let balance_key = token::storage_key::balance_key(
10071005
&shell.state.in_mem().native_token,
1008-
&Address::from(&keypair.ref_to()),
1006+
&address,
10091007
);
10101008
shell
10111009
.state
1012-
.write(&balance_key, Amount::native_whole(99))
1010+
.write(&balance_key, Amount::native_whole(GAS_LIMIT))
10131011
.unwrap();
1014-
let keypair = gen_keypair();
1012+
shell.commit();
1013+
// Verify that the public key associated with the fee payer has not been
1014+
// revealed
1015+
assert!(
1016+
namada_sdk::account::public_keys(&shell.state, &address)
1017+
.unwrap()
1018+
.is_empty()
1019+
);
10151020
let mut outer_tx =
10161021
Tx::from_type(TxType::Wrapper(Box::new(WrapperTx::new(
10171022
Fee {
@@ -1026,34 +1031,15 @@ mod test_process_proposal {
10261031
outer_tx.set_data(Data::new("transaction data".as_bytes().to_owned()));
10271032
outer_tx.sign_wrapper(keypair);
10281033

1029-
let response = {
1030-
let request = ProcessProposal {
1031-
txs: vec![outer_tx.to_bytes()],
1032-
};
1033-
if let Err(TestError::RejectProposal(resp)) =
1034-
shell.process_proposal(request)
1035-
{
1036-
if let [resp] = resp.as_slice() {
1037-
resp.clone()
1038-
} else {
1039-
panic!("Test failed")
1040-
}
1041-
} else {
1042-
panic!("Test failed")
1043-
}
1034+
let request = ProcessProposal {
1035+
txs: vec![outer_tx.to_bytes()],
10441036
};
1045-
assert_eq!(response.result.code, u32::from(ResultCode::FeeError));
1046-
assert!(response.result.info.contains(
1047-
"Error trying to apply a transaction: Error while processing \
1048-
transaction's fees: The first transaction in the batch failed to \
1049-
pay fees via the MASP. Wasm run failed: Transaction runner \
1050-
error: Wasm validation error"
1051-
));
1037+
let response = shell.process_proposal(request).unwrap();
1038+
assert_eq!(response[0].result.code, u32::from(ResultCode::Ok));
10521039
}
10531040

1054-
/// Test that if the account submitting the tx does
1055-
/// not have sufficient balance to pay the fee,
1056-
/// [`process_proposal`] rejects the entire block
1041+
/// Test that if the account submitting the tx does not have sufficient
1042+
/// balance to pay the fee, [`process_proposal`] rejects the entire block
10571043
#[test]
10581044
fn test_wrapper_insufficient_balance_address() {
10591045
let (mut shell, _recv, _, _) = test_utils::setup_at_height(3u64);

0 commit comments

Comments
 (0)