mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 23:27:56 -05:00
contract/money/tests: erroneous txs assert added
This commit is contained in:
@@ -56,41 +56,49 @@ async fn money_integration() -> Result<()> {
|
||||
th.airdrop_native(200, th.alice.keypair.public)?;
|
||||
|
||||
info!("[Faucet] Executing Alice airdrop tx");
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice_airdrop_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(alice_airdrop_params.outputs[0].coin.inner()));
|
||||
|
||||
info!("[Alice] Executing Alice airdrop tx");
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice_airdrop_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(alice_airdrop_params.outputs[0].coin.inner()));
|
||||
// Alice has to witness this coin because it's hers.
|
||||
let leaf_position = th.alice.merkle_tree.witness().unwrap();
|
||||
|
||||
info!("[Bob] Executing Alice airdrop tx");
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice_airdrop_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(alice_airdrop_params.outputs[0].coin.inner()));
|
||||
|
||||
info!("[Charlie] Executing Alice airdrop tx");
|
||||
th.charlie
|
||||
let erroneous_txs = th
|
||||
.charlie
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice_airdrop_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.charlie.merkle_tree.append(&MerkleNode::from(alice_airdrop_params.outputs[0].coin.inner()));
|
||||
|
||||
assert_eq!(th.alice.merkle_tree.root(0).unwrap(), th.bob.merkle_tree.root(0).unwrap());
|
||||
@@ -114,39 +122,47 @@ async fn money_integration() -> Result<()> {
|
||||
th.mint_token(bob_token_authority, 500, th.charlie.keypair.public)?;
|
||||
|
||||
info!("[Faucet] Executing BOBTOKEN mint to Charlie");
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob_charlie_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(bob_charlie_mint_params.output.coin.inner()));
|
||||
|
||||
info!("[Alice] Executing BOBTOKEN mint to Charlie");
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob_charlie_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(bob_charlie_mint_params.output.coin.inner()));
|
||||
|
||||
info!("[Bob] Executing BOBTOKEN mint to Charlie");
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob_charlie_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(bob_charlie_mint_params.output.coin.inner()));
|
||||
|
||||
info!("[Charlie] Executing BOBTOKEN mint to Charlie");
|
||||
th.charlie
|
||||
let erroneous_txs = th
|
||||
.charlie
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob_charlie_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.charlie.merkle_tree.append(&MerkleNode::from(bob_charlie_mint_params.output.coin.inner()));
|
||||
// Charlie has to witness this coin because it's his.
|
||||
let leaf_position = th.charlie.merkle_tree.witness().unwrap();
|
||||
@@ -173,36 +189,44 @@ async fn money_integration() -> Result<()> {
|
||||
let (bob_frz_tx, _) = th.freeze_token(bob_token_authority)?;
|
||||
|
||||
info!("[Faucet] Executing BOBTOKEN freeze");
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob_frz_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
|
||||
info!("[Alice] Executing BOBTOKEN freeze");
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob_frz_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
|
||||
info!("[Bob] Executing BOBTOKEN freeze");
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob_frz_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
|
||||
info!("[Charlie] Executing BOBTOKEN freeze");
|
||||
th.charlie
|
||||
let erroneous_txs = th
|
||||
.charlie
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob_frz_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
|
||||
// Thanks for reading
|
||||
Ok(())
|
||||
|
||||
@@ -133,12 +133,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] Executing Alice token mint tx");
|
||||
info!(target: "money", "[Faucet] =============================");
|
||||
let timer = Instant::now();
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(alice_params.output.coin.inner()));
|
||||
mint_verify_times.push(timer.elapsed());
|
||||
|
||||
@@ -146,12 +148,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] Executing Bob token mint tx");
|
||||
info!(target: "money", "[Faucet] ===========================");
|
||||
let timer = Instant::now();
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(bob_params.output.coin.inner()));
|
||||
mint_verify_times.push(timer.elapsed());
|
||||
|
||||
@@ -159,12 +163,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Alice] Executing Alice token mint tx");
|
||||
info!(target: "money", "[Alice] =============================");
|
||||
let timer = Instant::now();
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(alice_params.output.coin.inner()));
|
||||
// Alice has to witness this coin because it's hers.
|
||||
let alice_leaf_pos = th.alice.merkle_tree.witness().unwrap();
|
||||
@@ -174,12 +180,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Alice] Executing Bob token mint tx");
|
||||
info!(target: "money", "[Alice] ===========================");
|
||||
let timer = Instant::now();
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(bob_params.output.coin.inner()));
|
||||
mint_verify_times.push(timer.elapsed());
|
||||
|
||||
@@ -187,12 +195,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Bob] Executing Alice token mint tx");
|
||||
info!(target: "money", "[Bob] =============================");
|
||||
let timer = Instant::now();
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(alice_params.output.coin.inner()));
|
||||
mint_verify_times.push(timer.elapsed());
|
||||
|
||||
@@ -200,12 +210,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Bob] Executing Bob token mint tx");
|
||||
info!(target: "money", "[Bob] ===========================");
|
||||
let timer = Instant::now();
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(bob_params.output.coin.inner()));
|
||||
let bob_leaf_pos = th.bob.merkle_tree.witness().unwrap();
|
||||
mint_verify_times.push(timer.elapsed());
|
||||
@@ -299,12 +311,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] Executing Alice2Bob payment tx");
|
||||
info!(target: "money", "[Faucet] ==============================");
|
||||
let timer = Instant::now();
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice2bob_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(alice2bob_params.outputs[0].coin.inner()));
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(alice2bob_params.outputs[1].coin.inner()));
|
||||
transfer_verify_times.push(timer.elapsed());
|
||||
@@ -313,12 +327,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Alice] Executing Alice2Bob payment tx");
|
||||
info!(target: "money", "[Alice] ==============================");
|
||||
let timer = Instant::now();
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice2bob_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(alice2bob_params.outputs[0].coin.inner()));
|
||||
let alice_leaf_pos = th.alice.merkle_tree.witness().unwrap();
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(alice2bob_params.outputs[1].coin.inner()));
|
||||
@@ -328,12 +344,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Bob] Executing Alice2Bob payment tx");
|
||||
info!(target: "money", "[Bob] ==============================");
|
||||
let timer = Instant::now();
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice2bob_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(alice2bob_params.outputs[0].coin.inner()));
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(alice2bob_params.outputs[1].coin.inner()));
|
||||
let bob_leaf_pos = th.bob.merkle_tree.witness().unwrap();
|
||||
@@ -431,12 +449,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] Executing Bob2Alice payment tx");
|
||||
info!(target: "money", "[Faucet] ==============================");
|
||||
let timer = Instant::now();
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob2alice_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(bob2alice_params.outputs[0].coin.inner()));
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(bob2alice_params.outputs[1].coin.inner()));
|
||||
transfer_verify_times.push(timer.elapsed());
|
||||
@@ -445,12 +465,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Alice] Executing Bob2Alice payment tx");
|
||||
info!(target: "money", "[Alice] ==============================");
|
||||
let timer = Instant::now();
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob2alice_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(bob2alice_params.outputs[0].coin.inner()));
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(bob2alice_params.outputs[1].coin.inner()));
|
||||
let alice_leaf_pos = th.alice.merkle_tree.witness().unwrap();
|
||||
@@ -460,12 +482,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Bob] Executing Bob2Alice payment tx");
|
||||
info!(target: "money", "[Bob] ==================+===========");
|
||||
let timer = Instant::now();
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob2alice_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(bob2alice_params.outputs[0].coin.inner()));
|
||||
let bob_leaf_pos = th.bob.merkle_tree.witness().unwrap();
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(bob2alice_params.outputs[1].coin.inner()));
|
||||
@@ -622,12 +646,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] Executing AliceBob swap tx");
|
||||
info!(target: "money", "[Faucet] ==========================");
|
||||
let timer = Instant::now();
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alicebob_swap_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[0].coin.inner()));
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[1].coin.inner()));
|
||||
swap_verify_times.push(timer.elapsed());
|
||||
@@ -636,12 +662,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Alice] Executing AliceBob swap tx");
|
||||
info!(target: "money", "[Alice] ==========================");
|
||||
let timer = Instant::now();
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alicebob_swap_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[0].coin.inner()));
|
||||
let alice_leaf_pos = th.alice.merkle_tree.witness().unwrap();
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[1].coin.inner()));
|
||||
@@ -651,12 +679,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Bob] Executing AliceBob swap tx");
|
||||
info!(target: "money", "[Bob] ==========================");
|
||||
let timer = Instant::now();
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alicebob_swap_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[0].coin.inner()));
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[1].coin.inner()));
|
||||
let bob_leaf_pos = th.bob.merkle_tree.witness().unwrap();
|
||||
@@ -758,12 +788,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] Executing Alice2Alice payment tx");
|
||||
info!(target: "money", "[Faucet] ================================");
|
||||
let timer = Instant::now();
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice2alice_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(alice2alice_params.outputs[0].coin.inner()));
|
||||
transfer_verify_times.push(timer.elapsed());
|
||||
|
||||
@@ -771,12 +803,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Alice] Executing Alice2Alice payment tx");
|
||||
info!(target: "money", "[Alice] ================================");
|
||||
let timer = Instant::now();
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice2alice_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(alice2alice_params.outputs[0].coin.inner()));
|
||||
let alice_leaf_pos = th.alice.merkle_tree.witness().unwrap();
|
||||
transfer_verify_times.push(timer.elapsed());
|
||||
@@ -785,12 +819,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Bob] Executing Alice2Alice payment tx");
|
||||
info!(target: "money", "[Bob] ================================");
|
||||
let timer = Instant::now();
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice2alice_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(alice2alice_params.outputs[0].coin.inner()));
|
||||
transfer_verify_times.push(timer.elapsed());
|
||||
|
||||
@@ -875,12 +911,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] Executing Bob2Bob payment tx");
|
||||
info!(target: "money", "[Faucet] ============================");
|
||||
let timer = Instant::now();
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob2bob_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(bob2bob_params.outputs[0].coin.inner()));
|
||||
transfer_verify_times.push(timer.elapsed());
|
||||
|
||||
@@ -888,12 +926,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Alice] Executing Bob2Bob payment tx");
|
||||
info!(target: "money", "[Alice] ============================");
|
||||
let timer = Instant::now();
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob2bob_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(bob2bob_params.outputs[0].coin.inner()));
|
||||
transfer_verify_times.push(timer.elapsed());
|
||||
|
||||
@@ -901,12 +941,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Bob] Executing Bob2Bob payment tx");
|
||||
info!(target: "money", "[Bob] ============================");
|
||||
let timer = Instant::now();
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[bob2bob_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(bob2bob_params.outputs[0].coin.inner()));
|
||||
let bob_leaf_pos = th.bob.merkle_tree.witness().unwrap();
|
||||
transfer_verify_times.push(timer.elapsed());
|
||||
@@ -1040,12 +1082,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] Executing AliceBob swap tx");
|
||||
info!(target: "money", "[Faucet] ==========================");
|
||||
let timer = Instant::now();
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alicebob_swap_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[0].coin.inner()));
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[1].coin.inner()));
|
||||
swap_verify_times.push(timer.elapsed());
|
||||
@@ -1054,12 +1098,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Alice] Executing AliceBob swap tx");
|
||||
info!(target: "money", "[Alice] ==========================");
|
||||
let timer = Instant::now();
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alicebob_swap_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[0].coin.inner()));
|
||||
let alice_leaf_pos = th.alice.merkle_tree.witness().unwrap();
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[1].coin.inner()));
|
||||
@@ -1069,12 +1115,14 @@ async fn money_contract_transfer() -> Result<()> {
|
||||
info!(target: "money", "[Bob] Executing AliceBob swap tx");
|
||||
info!(target: "money", "[Bob] ==========================");
|
||||
let timer = Instant::now();
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alicebob_swap_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[0].coin.inner()));
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(swap_full_params.outputs[1].coin.inner()));
|
||||
let bob_leaf_pos = th.bob.merkle_tree.witness().unwrap();
|
||||
|
||||
@@ -85,23 +85,27 @@ async fn txs_verification() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] =============================");
|
||||
info!(target: "money", "[Faucet] Executing Alice token mint tx");
|
||||
info!(target: "money", "[Faucet] =============================");
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(alice_params.output.coin.inner()));
|
||||
|
||||
info!(target: "money", "[Alice] =============================");
|
||||
info!(target: "money", "[Alice] Executing Alice token mint tx");
|
||||
info!(target: "money", "[Alice] =============================");
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(alice_params.output.coin.inner()));
|
||||
// Alice has to witness this coin because it's hers.
|
||||
let alice_leaf_pos = th.alice.merkle_tree.witness().unwrap();
|
||||
@@ -109,12 +113,14 @@ async fn txs_verification() -> Result<()> {
|
||||
info!(target: "money", "[Bob] =============================");
|
||||
info!(target: "money", "[Bob] Executing Alice token mint tx");
|
||||
info!(target: "money", "[Bob] =============================");
|
||||
th.bob
|
||||
let erroneous_txs = th
|
||||
.bob
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[alice_mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(alice_params.output.coin.inner()));
|
||||
|
||||
assert!(th.alice.merkle_tree.root(0).unwrap() == th.bob.merkle_tree.root(0).unwrap());
|
||||
@@ -232,7 +238,9 @@ async fn txs_verification() -> Result<()> {
|
||||
let erroneous_txs =
|
||||
th.faucet.state.read().await.verify_transactions(&transactions, current_slot, true).await?;
|
||||
assert_eq!(erroneous_txs.len(), duplicates - 1);
|
||||
th.faucet.state.read().await.verify_transactions(&valid_txs, current_slot, true).await?;
|
||||
let erroneous_txs =
|
||||
th.faucet.state.read().await.verify_transactions(&valid_txs, current_slot, true).await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(txs_params[0].outputs[0].coin.inner()));
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(txs_params[0].outputs[1].coin.inner()));
|
||||
|
||||
@@ -242,7 +250,9 @@ async fn txs_verification() -> Result<()> {
|
||||
let erroneous_txs =
|
||||
th.alice.state.read().await.verify_transactions(&transactions, current_slot, true).await?;
|
||||
assert_eq!(erroneous_txs.len(), duplicates - 1);
|
||||
th.alice.state.read().await.verify_transactions(&valid_txs, current_slot, true).await?;
|
||||
let erroneous_txs =
|
||||
th.alice.state.read().await.verify_transactions(&valid_txs, current_slot, true).await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(txs_params[0].outputs[0].coin.inner()));
|
||||
let alice_leaf_pos = th.alice.merkle_tree.witness().unwrap();
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(txs_params[0].outputs[1].coin.inner()));
|
||||
@@ -253,7 +263,9 @@ async fn txs_verification() -> Result<()> {
|
||||
let erroneous_txs =
|
||||
th.bob.state.read().await.verify_transactions(&transactions, current_slot, true).await?;
|
||||
assert_eq!(erroneous_txs.len(), duplicates - 1);
|
||||
th.bob.state.read().await.verify_transactions(&valid_txs, current_slot, true).await?;
|
||||
let erroneous_txs =
|
||||
th.bob.state.read().await.verify_transactions(&valid_txs, current_slot, true).await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(txs_params[0].outputs[0].coin.inner()));
|
||||
th.bob.merkle_tree.append(&MerkleNode::from(txs_params[0].outputs[1].coin.inner()));
|
||||
let bob_leaf_pos = th.bob.merkle_tree.witness().unwrap();
|
||||
|
||||
@@ -74,22 +74,26 @@ async fn alice2alice_random_amounts() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] ==========================");
|
||||
info!(target: "money", "[Faucet] Executing Alice airdrop tx");
|
||||
info!(target: "money", "[Faucet] ==========================");
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[airdrop_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(airdrop_params.outputs[0].coin.inner()));
|
||||
info!(target: "money", "[Alice] ==========================");
|
||||
info!(target: "money", "[Alice] Executing Alice airdrop tx");
|
||||
info!(target: "money", "[Alice] ==========================");
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[airdrop_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(airdrop_params.outputs[0].coin.inner()));
|
||||
|
||||
assert!(th.faucet.merkle_tree.root(0).unwrap() == th.alice.merkle_tree.root(0).unwrap());
|
||||
@@ -165,14 +169,28 @@ async fn alice2alice_random_amounts() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] ================================");
|
||||
info!(target: "money", "[Faucet] Executing Alice2Alice payment tx");
|
||||
info!(target: "money", "[Faucet] ================================");
|
||||
th.faucet.state.read().await.verify_transactions(&[tx.clone()], current_slot, true).await?;
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
for output in ¶ms.outputs {
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(output.coin.inner()));
|
||||
}
|
||||
info!(target: "money", "[Alice] ================================");
|
||||
info!(target: "money", "[Alice] Executing Alice2Alice payment tx");
|
||||
info!(target: "money", "[Alice] ================================");
|
||||
th.alice.state.read().await.verify_transactions(&[tx.clone()], current_slot, true).await?;
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
// Gather new owncoins and apply the state transitions
|
||||
for output in params.outputs {
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(output.coin.inner()));
|
||||
@@ -239,22 +257,26 @@ async fn alice2alice_random_amounts_multiplecoins() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] =======================");
|
||||
info!(target: "money", "[Faucet] Executing Alice mint tx");
|
||||
info!(target: "money", "[Faucet] =======================");
|
||||
th.faucet
|
||||
let erroneous_txs = th
|
||||
.faucet
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.faucet.merkle_tree.append(&MerkleNode::from(mint_params.output.coin.inner()));
|
||||
info!(target: "money", "[Alice] =======================");
|
||||
info!(target: "money", "[Alice] Executing Alice mint tx");
|
||||
info!(target: "money", "[Alice] =======================");
|
||||
th.alice
|
||||
let erroneous_txs = th
|
||||
.alice
|
||||
.state
|
||||
.read()
|
||||
.await
|
||||
.verify_transactions(&[mint_tx.clone()], current_slot, true)
|
||||
.await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
th.alice.merkle_tree.append(&MerkleNode::from(mint_params.output.coin.inner()));
|
||||
|
||||
assert!(th.faucet.merkle_tree.root(0).unwrap() == th.alice.merkle_tree.root(0).unwrap());
|
||||
@@ -377,11 +399,15 @@ async fn alice2alice_random_amounts_multiplecoins() -> Result<()> {
|
||||
info!(target: "money", "[Faucet] ================================");
|
||||
info!(target: "money", "[Faucet] Executing Alice2Alice payment tx");
|
||||
info!(target: "money", "[Faucet] ================================");
|
||||
th.faucet.state.read().await.verify_transactions(&txs, current_slot, true).await?;
|
||||
let erroneous_txs =
|
||||
th.faucet.state.read().await.verify_transactions(&txs, current_slot, true).await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
info!(target: "money", "[Alice] ================================");
|
||||
info!(target: "money", "[Alice] Executing Alice2Alice payment tx");
|
||||
info!(target: "money", "[Alice] ================================");
|
||||
th.alice.state.read().await.verify_transactions(&txs, current_slot, true).await?;
|
||||
let erroneous_txs =
|
||||
th.alice.state.read().await.verify_transactions(&txs, current_slot, true).await?;
|
||||
assert!(erroneous_txs.is_empty());
|
||||
|
||||
assert!(th.faucet.merkle_tree.root(0).unwrap() == th.alice.merkle_tree.root(0).unwrap());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user