Skip to content

Commit

Permalink
More WIP tests
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Nov 15, 2023
1 parent 6c6346a commit 5e08245
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 17 deletions.
34 changes: 17 additions & 17 deletions rusk/src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,23 @@ impl Rusk {
});
}
Err(_) => {
let root = hex::encode(session.root());
println!("UNSPENDABLE ; Resulting root: {root}");

let mut new_session = new_genesis_session(&inner.vm);
mem::swap(&mut session, &mut new_session);

let commited_root = new_session.commit()?;
let commited_root_hex = hex::encode(commited_root);
println!(
"Commited root after UNSPENDABLE: {commited_root_hex}"
);

session = rusk_abi::new_session(
&inner.vm,
commited_root,
block_height,
)?;
// let root = hex::encode(session.root());
// println!("UNSPENDABLE ; Resulting root: {root}");

// let mut new_session = new_genesis_session(&inner.vm);
// mem::swap(&mut session, &mut new_session);

// let commited_root = new_session.commit()?;
// let commited_root_hex = hex::encode(commited_root);
// println!(
// "Commited root after UNSPENDABLE: {commited_root_hex}"
// );

// session = rusk_abi::new_session(
// &inner.vm,
// commited_root,
// block_height,
// )?;

// An unspendable transaction should be discarded
discarded_txs.push(unspent_tx);
Expand Down
31 changes: 31 additions & 0 deletions rusk/tests/services/unspendable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ fn make_transactions(
)
.expect("Making the transaction should succeed");


// The second transaction will also be a `wallet.execute` to the transfer
// contract, but with no enough gas to spend. Transaction should be
// discarded
let tx_1_bis = wallet
.execute(
&mut rng,
TRANSFER_CONTRACT.to_bytes().into(),
String::from("root"),
(),
SENDER_INDEX_1,
&refund_1,
GAS_LIMIT_1,
1,
)
.expect("Making the transaction should succeed");

// The third transaction transaction will also be a `wallet.execute` to the
// transfer contract, querying for the root of the tree. This will be
// tested for gas cost.
Expand All @@ -143,6 +160,20 @@ fn make_transactions(
executed: 2,
};

let spent_transactions = generator_procedure(
rusk,
&[tx_0.clone(), tx_1_bis.clone(), tx_2.clone()],
BLOCK_HEIGHT,
BLOCK_GAS_LIMIT,
Some(expected),
);
// .expect("generator procedure should succeed");

let expected = ExecuteResult {
discarded: 1,
executed: 2,
};

let spent_transactions = generator_procedure(
rusk,
&[tx_0, tx_1, tx_2],
Expand Down

0 comments on commit 5e08245

Please sign in to comment.