Skip to content

Commit

Permalink
rusk: adapt deployment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Sep 12, 2024
1 parent 8280bf8 commit 9dc5e48
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
14 changes: 14 additions & 0 deletions rusk/tests/config/multi_transfer_deploy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[[phoenix_balance]]
address = "ivmscertKgRyX8wNMJJsQcSVEyPsfSMUQXSAgeAPQXsndqFq9Pmknzhm61QvcEEdxPaGgxDS4RHpb6KKccrnSKN"
seed = 57005
notes = [10_000_000_000]

[[phoenix_balance]]
address = "3MoVQ6VfGNu8fJ5GeHPRDVUfxcsDEmGXpWhvKhXY7F2dKCp7QWRw8RqPcbuJGdRqeTtxpuiwETnGAJLnhT4Kq4e8"
seed = 57005
notes = [10_000_000_000]

[[phoenix_balance]]
address = "4RyaodGmN8MyUDmpRrtRxJJhrVW2HsY2ycRUnRUXR97JCN1GHraQT9Ygb8yYo7oKzyZg2EXXCGkHBwoeNb96BKtQ"
seed = 57005
notes = [1_000_000_000_000]
16 changes: 13 additions & 3 deletions rusk/tests/services/multi_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const BLOCK_HEIGHT: u64 = 1;
const BLOCK_GAS_LIMIT: u64 = 24_000_000;
const GAS_LIMIT: u64 = 12_000_000; // Lowest value for a transfer
const INITIAL_BALANCE: u64 = 10_000_000_000;
const INITIAL_BALANCE_DEPLOY: u64 = 1_000_000_000_000;

const BOB_BYTECODE: &[u8] = include_bytes!(
"../../../target/dusk/wasm32-unknown-unknown/release/bob.wasm"
Expand All @@ -39,6 +40,15 @@ fn initial_state<P: AsRef<Path>>(dir: P) -> Result<Rusk> {
new_state(dir, &snapshot, BLOCK_GAS_LIMIT)
}

// Creates the Rusk initial state for the tests below
fn initial_state_deploy<P: AsRef<Path>>(dir: P) -> Result<Rusk> {
let snapshot =
toml::from_str(include_str!("../config/multi_transfer_deploy.toml"))
.expect("Cannot deserialize config");

new_state(dir, &snapshot, BLOCK_GAS_LIMIT)
}

/// Executes three different transactions in the same block, expecting only two
/// to be included due to exceeding the block gas limit
fn wallet_transfer(
Expand Down Expand Up @@ -218,7 +228,7 @@ fn wallet_transfer_deploy(
"Wrong initial balance for the sender"
);
assert_eq!(
initial_balance_2, INITIAL_BALANCE,
initial_balance_2, INITIAL_BALANCE_DEPLOY,
"Wrong initial balance for the sender"
);

Expand Down Expand Up @@ -255,7 +265,7 @@ fn wallet_transfer_deploy(
init_args,
0,
GAS_LIMIT,
1,
20_000,
)
.expect("Failed to deploy");
txs.push(tx);
Expand Down Expand Up @@ -387,7 +397,7 @@ pub async fn multi_transfer_deploy() -> Result<()> {
logger();

let tmp = tempdir().expect("Should be able to create temporary directory");
let rusk = initial_state(&tmp)?;
let rusk = initial_state_deploy(&tmp)?;

let cache = Arc::new(RwLock::new(HashMap::new()));

Expand Down

0 comments on commit 9dc5e48

Please sign in to comment.