Skip to content

Commit

Permalink
Fixes unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco authored and bengtlofgren committed May 11, 2023
1 parent 2db65d0 commit bac318c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
29 changes: 25 additions & 4 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,26 @@ mod test_finalize_block {
let keypair = gen_keypair();
let mut processed_txs = vec![];
let mut valid_wrappers = vec![];

// Add unshielded balance for fee paymenty
let balance_key = token::balance_key(
&shell.storage.native_token,
&Address::from(&keypair.ref_to()),
);
shell
.storage
.write(&balance_key, Amount::from(1000).try_to_vec().unwrap())
.unwrap();

// create some wrapper txs
for i in 1..5 {
for i in 1u64..5 {
let raw_tx = Tx::new(
"wasm_code".as_bytes().to_owned(),
Some(format!("transaction data: {}", i).as_bytes().to_owned()),
);
let wrapper = WrapperTx::new(
Fee {
amount: i.into(),
amount: 100.into(),
token: shell.storage.native_token.clone(),
},
&keypair,
Expand Down Expand Up @@ -603,6 +614,16 @@ mod test_finalize_block {
let mut processed_txs = vec![];
let mut valid_txs = vec![];

// Add unshielded balance for fee paymenty
let balance_key = token::balance_key(
&shell.storage.native_token,
&Address::from(&keypair.ref_to()),
);
shell
.storage
.write(&balance_key, Amount::from(1000).try_to_vec().unwrap())
.unwrap();

// create two decrypted txs
let mut wasm_path = top_level_directory();
wasm_path.push("wasm_for_tests/tx_no_op.wasm");
Expand All @@ -619,7 +640,7 @@ mod test_finalize_block {
);
let wrapper_tx = WrapperTx::new(
Fee {
amount: 0.into(),
amount: 100.into(),
token: shell.storage.native_token.clone(),
},
&keypair,
Expand Down Expand Up @@ -650,7 +671,7 @@ mod test_finalize_block {
);
let wrapper_tx = WrapperTx::new(
Fee {
amount: 0.into(),
amount: 100.into(),
token: shell.storage.native_token.clone(),
},
&keypair,
Expand Down
9 changes: 9 additions & 0 deletions apps/src/lib/node/ledger/shell/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,15 @@ mod test_process_proposal {
..Default::default()
});
let keypair = crate::wallet::defaults::daewon_keypair();
// reduce address balance to match the 100 token fee
let balance_key = token::balance_key(
&shell.storage.native_token,
&Address::from(&keypair.ref_to()),
);
shell
.storage
.write(&balance_key, Amount::from(99).try_to_vec().unwrap())
.unwrap();

let tx = Tx::new(
"wasm_code".as_bytes().to_owned(),
Expand Down

0 comments on commit bac318c

Please sign in to comment.