Skip to content

Commit

Permalink
fix(CI): advance after transactions are fully finalized (#982)
Browse files Browse the repository at this point in the history
  • Loading branch information
miraclx authored Nov 22, 2024
1 parent e6cd59f commit 8b26910
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion contracts/context-config/tests/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,6 @@ async fn test_storage_usage_matches_code_size() -> eyre::Result<()> {

let node1_balance = worker.view_account(&node1.id()).await?.balance;

// Deploy proxy contract
let res = node1
.call(contract.id(), "mutate")
.args_json(Signed::new(
Expand Down Expand Up @@ -1155,11 +1154,15 @@ async fn test_storage_usage_matches_code_size() -> eyre::Result<()> {
let expected_log = format!("Context `{}` added", context_id);
assert!(res.logs().iter().any(|log| log == &expected_log));

worker.fast_forward(1).await?;

let node1_balance_after = worker.view_account(&node1.id()).await?.balance;

let diff = node1_balance.saturating_sub(node1_balance_after);
let node1_balance = node1_balance_after;

println!("Node1 balance diff: {}", diff);

assert!(
diff < NearToken::from_millinear(10),
"Node1 balance should not be reduced by more than 10 milliNEAR, but was reduced by {}",
Expand All @@ -1185,6 +1188,7 @@ async fn test_storage_usage_matches_code_size() -> eyre::Result<()> {
println!("Initial storage usage: {}", initial_storage);
println!("Initial WASM size: {}", initial_code_size);
println!("Initial Balance: {}", initial_balance);
println!("Initial Node1 Balance: {}", node1_balance);

let res = contract
.call("set_proxy_code")
Expand Down Expand Up @@ -1216,11 +1220,15 @@ async fn test_storage_usage_matches_code_size() -> eyre::Result<()> {

assert!(res.failures().is_empty(), "{:#?}", res.failures());

worker.fast_forward(1).await?;

let node1_balance_after = worker.view_account(&node1.id()).await?.balance;

let diff = node1_balance.saturating_sub(node1_balance_after);
let node1_balance = node1_balance_after;

println!("Node1 balance diff: {}", diff);

assert!(
diff < NearToken::from_millinear(10),
"Node1 balance should not be reduced by more than 10 milliNEAR, but was reduced by {}",
Expand All @@ -1236,6 +1244,7 @@ async fn test_storage_usage_matches_code_size() -> eyre::Result<()> {
println!("Intermediate storage usage: {}", intermediate_storage);
println!("Intermediate WASM size: {}", intermediate_code_size);
println!("Intermediate Balance: {}", intermediate_balance);
println!("Intermediate Node1 Balance: {}", node1_balance);

// Calculate raw differences (can be negative)
let storage_change = intermediate_storage as i64 - initial_storage as i64;
Expand Down Expand Up @@ -1291,10 +1300,14 @@ async fn test_storage_usage_matches_code_size() -> eyre::Result<()> {

assert!(res.failures().is_empty(), "{:#?}", res.failures());

worker.fast_forward(1).await?;

let node1_balance_after = worker.view_account(&node1.id()).await?.balance;

let diff = node1_balance.saturating_sub(node1_balance_after);

println!("Node1 balance diff: {}", diff);

assert!(
diff < NearToken::from_millinear(10),
"Node1 balance should not be reduced by more than 10 milliNEAR, but was reduced by {}",
Expand All @@ -1310,6 +1323,7 @@ async fn test_storage_usage_matches_code_size() -> eyre::Result<()> {
println!("Final storage usage: {}", final_storage);
println!("Final WASM size: {}", final_code_size);
println!("Final Balance: {}", final_balance);
println!("Final Node1 Balance: {}", node1_balance);

// Calculate raw differences (can be negative)
let storage_change = final_storage as i64 - intermediate_storage as i64;
Expand Down

0 comments on commit 8b26910

Please sign in to comment.