Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi transfer - add test with one egld multi transfer #1965

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ pub async fn adder_cli() {
Some(payable_interactor_cli::InteractCliCommand::AllTransfers) => {
basic_interact.check_all_transfers().await;
},
Some(payable_interactor_cli::InteractCliCommand::MultiTransferWithOneEGLD) => {
basic_interact
.check_multi_transfer_single_egld_transfer()
.await;
},
None => {},
}
}
Expand Down Expand Up @@ -73,6 +78,26 @@ impl PayableInteract {
self.state.set_adder_address(new_address);
}

pub async fn check_multi_transfer_single_egld_transfer(&mut self) {
let mut payment = MultiEgldOrEsdtPayment::new();
payment.push(EgldOrEsdtTokenPayment::egld_payment(1_0000u64.into()));

let result = self
.interactor
.tx()
.from(&self.wallet_address)
.to(self.state.current_payable_features_address())
.gas(6_000_000u64)
.typed(payable_features_proxy::PayableFeaturesProxy)
.payable_all_transfers()
.payment(payment)
.returns(ReturnsResult)
.run()
.await;

println!("Result: {result:?}");
}

pub async fn check_all_transfers(&mut self) {
let mut payment = MultiEgldOrEsdtPayment::new();
payment.push(EgldOrEsdtTokenPayment::egld_payment(1_0000u64.into()));
Expand All @@ -82,7 +107,7 @@ impl PayableInteract {
.interactor
.tx()
.from(&self.wallet_address)
.to(self.state.current_adder_address())
.to(self.state.current_payable_features_address())
.gas(6_000_000u64)
.typed(payable_features_proxy::PayableFeaturesProxy)
.payable_all_transfers()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ pub enum InteractCliCommand {
Deploy,
#[command(name = "at", about = "Check all transfers")]
AllTransfers,
#[command(name = "mt", about = "Check multi transfer with one EGLD")]
MultiTransferWithOneEGLD,
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use std::{
/// State file
const STATE_FILE: &str = "state.toml";

/// Adder Interact state
/// Payable Features Interact state
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct State {
adder_address: Option<Bech32Address>,
payable_features_address: Option<Bech32Address>,
}

impl State {
Expand All @@ -29,12 +29,12 @@ impl State {

/// Sets the adder address
pub fn set_adder_address(&mut self, address: Bech32Address) {
self.adder_address = Some(address);
self.payable_features_address = Some(address);
}

/// Returns the adder contract
pub fn current_adder_address(&self) -> &Bech32Address {
self.adder_address
pub fn current_payable_features_address(&self) -> &Bech32Address {
self.payable_features_address
.as_ref()
.expect("no known adder contract, deploy first")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// use multiversx_sc_snippets::{imports::Bech32Address, sdk::gateway::SetStateAccount, test_wallets};
use payable_interactor::{Config, PayableInteract};
use serial_test::serial;

#[tokio::test]
#[serial]
#[cfg_attr(not(feature = "chain-simulator-tests"), ignore)]
async fn simulator_upgrade_test() {
let mut payable_interact = PayableInteract::new(Config::chain_simulator_config()).await;

payable_interact.deploy().await;

payable_interact.check_all_transfers().await;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"steps": [
{
"step": "setState",
"accounts": {
"address:a_user": {
"nonce": "0",
"balance": "10000000000"
},
"sc:payable": {
"nonce": "0",
"balance": "0",
"esdt": {},
"code": "mxsc:../output/payable-features.mxsc.json"
}
}
},
{
"step": "scCall",
"id": "",
"tx": {
"from": "address:a_user",
"to": "sc:payable",
"esdtValue": [
{
"tokenIdentifier": "str:EGLD-000000",
"value": "10000"
}
],
"function": "payable_all_transfers",
"arguments": [],
"gasLimit": "6000000"
}
},
{
"step": "checkState",
"accounts": {
"address:a_user": {
"nonce": "*",
"balance": "9999990000",
"storage": {},
"code": ""
},
"sc:payable": {
"nonce": "*",
"balance": "10000",
"storage": {},
"code": ""
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ fn payable_all_transfers_go() {
world().run("scenarios/payable_all_transfers.scen.json");
}

#[test]
fn payable_all_transfers_2_go() {
world().run("scenarios/payable_all_transfers_2.scen.json");
}

#[test]
fn payable_any_1_go() {
world().run("scenarios/payable_any_1.scen.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ fn payable_all_transfers_rs() {
world().run("scenarios/payable_all_transfers.scen.json");
}

#[test]
fn payable_all_transfers_2_go() {
world().run("scenarios/payable_all_transfers_2.scen.json");
}

#[test]
fn payable_any_1_rs() {
world().run("scenarios/payable_any_1.scen.json");
Expand Down
Loading