-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add blackbox test for builtin_func_features
- Loading branch information
1 parent
6fe9d6e
commit 213d255
Showing
4 changed files
with
248 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
...acts/feature-tests/composability/builtin-func-features/src/builtin_func_features_proxy.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
// Code generated by the multiversx-sc proxy generator. DO NOT EDIT. | ||
|
||
//////////////////////////////////////////////////// | ||
////////////////// AUTO-GENERATED ////////////////// | ||
//////////////////////////////////////////////////// | ||
|
||
#![allow(dead_code)] | ||
#![allow(clippy::all)] | ||
|
||
use multiversx_sc::proxy_imports::*; | ||
|
||
pub struct BuiltinFuncFeaturesProxy; | ||
|
||
impl<Env, From, To, Gas> TxProxyTrait<Env, From, To, Gas> for BuiltinFuncFeaturesProxy | ||
where | ||
Env: TxEnv, | ||
From: TxFrom<Env>, | ||
To: TxTo<Env>, | ||
Gas: TxGas<Env>, | ||
{ | ||
type TxProxyMethods = BuiltinFuncFeaturesProxyMethods<Env, From, To, Gas>; | ||
|
||
fn proxy_methods(self, tx: Tx<Env, From, To, (), Gas, (), ()>) -> Self::TxProxyMethods { | ||
BuiltinFuncFeaturesProxyMethods { wrapped_tx: tx } | ||
} | ||
} | ||
|
||
pub struct BuiltinFuncFeaturesProxyMethods<Env, From, To, Gas> | ||
where | ||
Env: TxEnv, | ||
From: TxFrom<Env>, | ||
To: TxTo<Env>, | ||
Gas: TxGas<Env>, | ||
{ | ||
wrapped_tx: Tx<Env, From, To, (), Gas, (), ()>, | ||
} | ||
|
||
#[rustfmt::skip] | ||
impl<Env, From, Gas> BuiltinFuncFeaturesProxyMethods<Env, From, (), Gas> | ||
where | ||
Env: TxEnv, | ||
Env::Api: VMApi, | ||
From: TxFrom<Env>, | ||
Gas: TxGas<Env>, | ||
{ | ||
pub fn init< | ||
Arg0: ProxyArg<TokenIdentifier<Env::Api>>, | ||
Arg1: ProxyArg<TokenIdentifier<Env::Api>>, | ||
>( | ||
self, | ||
fungible_token_id: Arg0, | ||
non_fungible_token_id: Arg1, | ||
) -> TxTypedDeploy<Env, From, NotPayable, Gas, ()> { | ||
self.wrapped_tx | ||
.payment(NotPayable) | ||
.raw_deploy() | ||
.argument(&fungible_token_id) | ||
.argument(&non_fungible_token_id) | ||
.original_result() | ||
} | ||
} | ||
|
||
#[rustfmt::skip] | ||
impl<Env, From, To, Gas> BuiltinFuncFeaturesProxyMethods<Env, From, To, Gas> | ||
where | ||
Env: TxEnv, | ||
Env::Api: VMApi, | ||
From: TxFrom<Env>, | ||
To: TxTo<Env>, | ||
Gas: TxGas<Env>, | ||
{ | ||
pub fn call_set_user_name< | ||
Arg0: ProxyArg<ManagedAddress<Env::Api>>, | ||
Arg1: ProxyArg<ManagedBuffer<Env::Api>>, | ||
>( | ||
self, | ||
address: Arg0, | ||
name: Arg1, | ||
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ()> { | ||
self.wrapped_tx | ||
.payment(NotPayable) | ||
.raw_call("call_set_user_name") | ||
.argument(&address) | ||
.argument(&name) | ||
.original_result() | ||
} | ||
|
||
pub fn call_delete_user_name< | ||
Arg0: ProxyArg<ManagedAddress<Env::Api>>, | ||
>( | ||
self, | ||
address: Arg0, | ||
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ()> { | ||
self.wrapped_tx | ||
.payment(NotPayable) | ||
.raw_call("call_delete_user_name") | ||
.argument(&address) | ||
.original_result() | ||
} | ||
|
||
pub fn transfer_fungible_promise_no_callback< | ||
Arg0: ProxyArg<ManagedAddress<Env::Api>>, | ||
Arg1: ProxyArg<BigUint<Env::Api>>, | ||
>( | ||
self, | ||
to: Arg0, | ||
amount: Arg1, | ||
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ()> { | ||
self.wrapped_tx | ||
.payment(NotPayable) | ||
.raw_call("transferFungiblePromiseNoCallback") | ||
.argument(&to) | ||
.argument(&amount) | ||
.original_result() | ||
} | ||
|
||
pub fn transfer_fungible_promise_with_callback< | ||
Arg0: ProxyArg<ManagedAddress<Env::Api>>, | ||
Arg1: ProxyArg<BigUint<Env::Api>>, | ||
>( | ||
self, | ||
to: Arg0, | ||
amount: Arg1, | ||
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ()> { | ||
self.wrapped_tx | ||
.payment(NotPayable) | ||
.raw_call("transferFungiblePromiseWithCallback") | ||
.argument(&to) | ||
.argument(&amount) | ||
.original_result() | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
...e-tests/composability/builtin-func-features/tests/esdt_transfer_promise_blackbox_tests.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
use multiversx_sc_scenario::imports::*; | ||
|
||
use builtin_func_features::*; | ||
|
||
const OWNER_ADDRESS: TestAddress = TestAddress::new("owner"); | ||
const USER_ADDRESS: TestAddress = TestAddress::new("user"); | ||
|
||
const BUILTIN_FEATURES_FUNC_ADDRESS: TestSCAddress = TestSCAddress::new("builtin-func-features"); | ||
const CODE_PATH: MxscPath = MxscPath::new("output/builtin-func-features.mxsc.json"); | ||
|
||
const FUNGIBLE_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("FUNG-123456"); | ||
const NON_FUNGIBLE_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("NONFUNG-123456"); | ||
|
||
fn world() -> ScenarioWorld { | ||
let mut blockchain = ScenarioWorld::new(); | ||
|
||
blockchain.set_current_dir_from_workspace( | ||
"contracts/feature-tests/composability/builtin-func-features", | ||
); | ||
blockchain.register_contract(CODE_PATH, builtin_func_features::ContractBuilder); | ||
blockchain | ||
} | ||
|
||
#[test] | ||
fn transfer_fungible_promise_no_callback_blackbox_test() { | ||
let mut world = world(); | ||
|
||
world | ||
.account(USER_ADDRESS) | ||
.nonce(1) | ||
.balance(1000) | ||
.esdt_balance(FUNGIBLE_TOKEN_ID, 1000) | ||
.esdt_balance(NON_FUNGIBLE_TOKEN_ID, 1000); | ||
|
||
world.start_trace(); | ||
|
||
world.account(OWNER_ADDRESS).nonce(1); | ||
|
||
let new_address = world | ||
.tx() | ||
.from(OWNER_ADDRESS) | ||
.typed(builtin_func_features_proxy::BuiltinFuncFeaturesProxy) | ||
.init(FUNGIBLE_TOKEN_ID, NON_FUNGIBLE_TOKEN_ID) | ||
.code(CODE_PATH) | ||
.new_address(BUILTIN_FEATURES_FUNC_ADDRESS) | ||
.returns(ReturnsNewAddress) | ||
.run(); | ||
|
||
assert_eq!(new_address, BUILTIN_FEATURES_FUNC_ADDRESS.to_address()); | ||
|
||
world | ||
.tx() | ||
.from(OWNER_ADDRESS) | ||
.to(BUILTIN_FEATURES_FUNC_ADDRESS) | ||
.typed(builtin_func_features_proxy::BuiltinFuncFeaturesProxy) | ||
.transfer_fungible_promise_no_callback(USER_ADDRESS, 1000u64) | ||
.run(); | ||
|
||
world | ||
.check_account(USER_ADDRESS) | ||
.esdt_balance(FUNGIBLE_TOKEN_ID, 1000u64); | ||
|
||
world | ||
.check_account(BUILTIN_FEATURES_FUNC_ADDRESS) | ||
.esdt_balance(FUNGIBLE_TOKEN_ID, 0u64); | ||
} | ||
|
||
#[test] | ||
fn transfer_fungible_promise_with_callback_blackbox_test() { | ||
let mut world = world(); | ||
|
||
world | ||
.account(USER_ADDRESS) | ||
.nonce(1) | ||
.balance(1000) | ||
.esdt_balance(FUNGIBLE_TOKEN_ID, 1000) | ||
.esdt_balance(NON_FUNGIBLE_TOKEN_ID, 1000); | ||
|
||
world.start_trace(); | ||
|
||
world.account(OWNER_ADDRESS).nonce(1); | ||
|
||
let new_address = world | ||
.tx() | ||
.from(OWNER_ADDRESS) | ||
.typed(builtin_func_features_proxy::BuiltinFuncFeaturesProxy) | ||
.init(FUNGIBLE_TOKEN_ID, NON_FUNGIBLE_TOKEN_ID) | ||
.code(CODE_PATH) | ||
.new_address(BUILTIN_FEATURES_FUNC_ADDRESS) | ||
.returns(ReturnsNewAddress) | ||
.run(); | ||
|
||
assert_eq!(new_address, BUILTIN_FEATURES_FUNC_ADDRESS.to_address()); | ||
|
||
world | ||
.tx() | ||
.from(OWNER_ADDRESS) | ||
.to(BUILTIN_FEATURES_FUNC_ADDRESS) | ||
.typed(builtin_func_features_proxy::BuiltinFuncFeaturesProxy) | ||
.transfer_fungible_promise_with_callback(USER_ADDRESS, 1000u64) | ||
.run(); | ||
|
||
world | ||
.check_account(USER_ADDRESS) | ||
.esdt_balance(FUNGIBLE_TOKEN_ID, 1000u64); | ||
|
||
world | ||
.check_account(BUILTIN_FEATURES_FUNC_ADDRESS) | ||
.esdt_balance(FUNGIBLE_TOKEN_ID, 0u64); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters