Skip to content

Commit

Permalink
improved test
Browse files Browse the repository at this point in the history
  • Loading branch information
akorchyn committed Sep 3, 2024
1 parent 2e64d9e commit 953d62f
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions near-sdk/src/environment/mock/mocked_blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ mod mock_chain {

#[cfg(test)]
mod tests {
use std::str::FromStr;

use near_gas::NearGas;
use near_primitives::types::GasWeight;
Expand Down Expand Up @@ -636,7 +637,15 @@ mod tests {
env::storage_remove(b"smile");
assert!(!env::storage_has_key(b"smile"));

assert_eq!(env::promise_results_count(), 1);
let promise_index = env::promise_create(
"account.near".parse().unwrap(),
"method",
&[],
NearToken::from_millinear(1),
NearGas::from_tgas(1),
);

env::promise_batch_action_stake(promise_index, NearToken::from_millinear(1), &public_key);

env::log_str("logged");

Expand All @@ -646,18 +655,30 @@ mod tests {

let actions = get_created_receipts();
assert_eq!(actions.len(), 1);
assert_eq!(actions[0].receiver_id, accounts(0));
assert_eq!(actions[0].actions.len(), 1);
assert_eq!(actions[0].receiver_id.to_string(), "account.near");
assert_eq!(actions[0].actions.len(), 2);
assert_eq!(
actions[0].actions[0],
MockAction::FunctionCallWeight {
receipt_index: 0,
method_name: b"hehe".to_vec(),
method_name: b"method".to_vec(),
args: [].to_vec(),
attached_deposit: NearToken::from_millinear(1),
prepaid_gas: NearGas::from_tgas(1),
gas_weight: GasWeight(0)
}
);

assert_eq!(
actions[0].actions[1],
MockAction::Stake {
receipt_index: 0,
stake: NearToken::from_millinear(1),
public_key: near_crypto::PublicKey::from_str(
"ed25519:H3C2AVAWKq5Qm7FkyDB5cHKcYKHgbiiB2BzX8DQX8CJ"
)
.unwrap()
}
);
}
}

0 comments on commit 953d62f

Please sign in to comment.