From f4cf49408a5e40e4b6e20b287ccd13995f7d151a Mon Sep 17 00:00:00 2001 From: Blake <104744707+r3v4s@users.noreply.github.com> Date: Wed, 19 Jun 2024 19:55:25 +0900 Subject: [PATCH] feat/use-TestSetRealm-in-testcases (#239) * feat: apply gno new testing api `TestSetRealm` * fix: typo filename --- README.md | 4 +- go.mod | 29 ---- go.sum | 140 ------------------ ... => __TEST_0_INIT_TOKEN_REGISTER_test.gno} | 0 ..._TEST_0_INIT_VARIABLE_AND_HELPER_test.gno} | 7 + ...test.gno => __TEST_Z_z0_rpc_filetest.gnoA} | 24 ++- ...no => __TEST_Z_z1_single_lp_filetest.gnoA} | 30 ++-- ... => __TEST_Z_z2_native_swap_filetest.gnoA} | 33 +++-- ..._TEST_Z_z3_dryswap_and_swap_filetest.gnoA} | 22 ++- ...ll_test.gnoA => __TEST_pool_all_test.gnoA} | 16 +- ...=> __TEST_pool_dryswap_and_swap_test.gnoA} | 13 +- ...gnoA => __TEST_pool_multi_token_test.gnoA} | 32 ++-- ...gnoA => __TEST_pool_native_swap_test.gnoA} | 16 +- ...t.gnoA => __TEST_pool_single_lp_test.gnoA} | 18 +-- ...T_pool_test.gnoA => __TEST_pool_test.gnoA} | 14 +- .../__TEST_0_INIT_VARS_HELPERS_test.gno | 8 + .../_TEST_/__TEST_Z_z1_position_filetest.gnoA | 42 ++++-- ...2_position_increase_decrease_filetest.gnoA | 31 ++-- ...wo_position_used_single_swap_filetest.gnoA | 33 +++-- position/_TEST_/__TEST_position_api_test.gnoA | 8 +- .../_TEST_/__TEST_position_full_test.gnoA | 10 +- ..._TEST_position_increase_decrease_test.gnoA | 22 +-- ...T_position_mint_swap_burn_left_B_test.gnoA | 54 +++---- ...T_position_mint_swap_burn_left_G_test.gnoA | 14 +- .../__TEST_position_mint_swap_owed_test.gnoA | 68 ++++----- ...osition_native_increase_decrease_test.gnoA | 10 +- ...ST_position_native_unclaimed_fee_test.gnoA | 14 +- ...n_pool_and_position_balance_diff_test.gnoA | 10 +- ...st_two_position_used_single_swap_test.gnoA | 12 +- .../__TEST_position_unclaimed_fee_test.gnoA | 24 +-- ... => __TEST_0_INIT_TOKEN_REGISTER_test.gno} | 0 ...no => __TEST_0_INIT_VARS_HELPERS_test.gno} | 8 + ...Z_z1_swap_route_1route_1hop_filetest.gnoA} | 33 +++-- ...route_1route_1hop_out_range_filetest.gnoA} | 22 ++- ...e_1route_1hop_native_in_out_filetest.gnoA} | 37 +++-- ..._1route_2hop_wrapped_middle_filetest.gnoA} | 40 +++-- ...=> __TEST_Z_z5_dry_and_swap_filetest.gnoA} | 90 ++++++----- ...__TEST_router_all_2_route_2_hop_test.gnoA} | 18 +-- ...route_1route_1hop_native_in_out_test.gnoA} | 10 +- ...wap_route_1route_1hop_out_range_test.gnoA} | 4 +- ...T_router_swap_route_1route_1hop_test.gnoA} | 20 +-- ...oute_2hop_wrapped_native_in_out_test.gnoA} | 10 +- ...oute_3hop_wrapped_native_middle_test.gnoA} | 14 +- ...T_router_swap_route_2route_2hop_test.gnoA} | 18 +-- ...__TEST_0_INIT_VARIABLE_AND_HELPER_test.gno | 11 ++ ...T_Z_z1_one_increase_external_filetest.gnoA | 29 +++- .../__TEST_Z_z2_one_external_filetest.gnoA | 33 +++-- ..._TEST_Z_z3_internal_external_filetest.gnoA | 48 +++--- .../__TEST_Z_z4_mint_and_stake_filetest.gnoA | 30 ++-- ...__TEST_Z_z5_manage_pool_tier_filetest.gnoA | 23 ++- .../__TEST_staker_collect_reward_test.gnoA | 26 ++-- .../_TEST_/__TEST_staker_external_test.gnoA | 18 +-- staker/_TEST_/__TEST_staker_full_test.gnoA | 26 ++-- staker/_TEST_/__TEST_staker_get_test.gnoA | 16 +- .../_TEST_/__TEST_staker_internal_test.gnoA | 16 +- .../__TEST_staker_manage_pool_tiers_test.gnoA | 2 +- .../__TEST_staker_mint_and_stake_test.gnoA | 14 +- ...er_native_create_collect_unstake_test.gnoA | 18 +-- ...EST_staker_one_increase_external_test.gnoA | 22 +-- staker/_TEST_/__TEST_staker_rpc_api_test.gnoA | 22 +-- 60 files changed, 735 insertions(+), 701 deletions(-) delete mode 100644 go.mod delete mode 100644 go.sum rename pool/_TEST_/{_TEST_0_INIT_TOKEN_REGISTER_test.gno => __TEST_0_INIT_TOKEN_REGISTER_test.gno} (100%) rename pool/_TEST_/{_TEST_0_INIT_VARIABLE_AND_HELPER_test.gno => __TEST_0_INIT_VARIABLE_AND_HELPER_test.gno} (89%) rename pool/_TEST_/{z0_rpc_filetest.gno => __TEST_Z_z0_rpc_filetest.gnoA} (94%) rename pool/_TEST_/{z1_single_lp_filetest.gno => __TEST_Z_z1_single_lp_filetest.gnoA} (96%) rename pool/_TEST_/{z2_native_swap_filetest.gno => __TEST_Z_z2_native_swap_filetest.gnoA} (91%) rename pool/_TEST_/{z3_dryswap_and_swap_filetest.gno => __TEST_Z_z3_dryswap_and_swap_filetest.gnoA} (95%) rename pool/_TEST_/{_TEST_pool_all_test.gnoA => __TEST_pool_all_test.gnoA} (91%) rename pool/_TEST_/{_TEST_pool_dryswap_and_swap_test.gnoA => __TEST_pool_dryswap_and_swap_test.gnoA} (94%) rename pool/_TEST_/{_TEST_pool_multi_token_test.gnoA => __TEST_pool_multi_token_test.gnoA} (95%) rename pool/_TEST_/{_TEST_pool_native_swap_test.gnoA => __TEST_pool_native_swap_test.gnoA} (94%) rename pool/_TEST_/{_TEST_pool_single_lp_test.gnoA => __TEST_pool_single_lp_test.gnoA} (98%) rename pool/_TEST_/{_TEST_pool_test.gnoA => __TEST_pool_test.gnoA} (92%) rename router/_TEST_/{_TEST_0_INIT_TOKEN_REGISTER_test.gno => __TEST_0_INIT_TOKEN_REGISTER_test.gno} (100%) rename router/_TEST_/{_TEST_0_INIT_VARS_HELPERS_test.gno => __TEST_0_INIT_VARS_HELPERS_test.gno} (87%) rename router/_TEST_/{z1_swap_route_1route_1hop_filetest.gno => __TEST_Z_z1_swap_route_1route_1hop_filetest.gnoA} (94%) rename router/_TEST_/{z2_swap_route_1route_1hop_out_range_filetest.gno => __TEST_Z_z2_swap_route_1route_1hop_out_range_filetest.gnoA} (94%) rename router/_TEST_/{z3_swap_route_1route_1hop_native_in_out_filetest.gno => __TEST_Z_z3_swap_route_1route_1hop_native_in_out_filetest.gnoA} (93%) rename router/_TEST_/{z4_swap_route_1route_2hop_wrapped_middle_filetest.gno => __TEST_Z_z4_swap_route_1route_2hop_wrapped_middle_filetest.gnoA} (92%) rename router/_TEST_/{z5_dry_and_swap_filetest.gno => __TEST_Z_z5_dry_and_swap_filetest.gnoA} (91%) rename router/_TEST_/{_TEST_router_all_2_route_2_hop_test.gnoA => __TEST_router_all_2_route_2_hop_test.gnoA} (98%) rename router/_TEST_/{_TEST_router_swap_route_1route_1hop_native_in_out_test.gnoA => __TEST_router_swap_route_1route_1hop_native_in_out_test.gnoA} (98%) rename router/_TEST_/{_TEST_router_swap_route_1route_1hop_out_range_test.gnoA => __TEST_router_swap_route_1route_1hop_out_range_test.gnoA} (98%) rename router/_TEST_/{_TEST_router_swap_route_1route_1hop_test.gnoA => __TEST_router_swap_route_1route_1hop_test.gnoA} (96%) rename router/_TEST_/{_TEST_router_swap_route_1route_2hop_wrapped_native_in_out_test.gnoA => __TEST_router_swap_route_1route_2hop_wrapped_native_in_out_test.gnoA} (97%) rename router/_TEST_/{_TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gnoA => __TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gnoA} (96%) rename router/_TEST_/{_TEST_router_swap_route_2route_2hop_test.gnoA => __TEST_router_swap_route_2route_2hop_test.gnoA} (98%) diff --git a/README.md b/README.md index 034c35c5..bd0ac009 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,13 @@ $ export WORKDIR=~/work ### Build Gno.land for Gnoswap -Clone the `gno` repository from `gnoswap-labs`. And switch to the `master_20240401` branch. You will be able to clone the repository and build it after running the following commands: +Clone the `gno` repository from `gnoswap-labs`. And switch to the `master_240619` branch. You will be able to clone the repository and build it after running the following commands: ``` $ cd $WORKDIR $ git clone https://github.com/gnoswap-labs/gno.git gno $ cd gno -$ git checkout master_gs +$ git checkout master_240619 $ make install ``` diff --git a/go.mod b/go.mod deleted file mode 100644 index de314ea4..00000000 --- a/go.mod +++ /dev/null @@ -1,29 +0,0 @@ -module github.com/gnoswap-labs/gnoswap - -go 1.21.3 - -require ( - github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect - github.com/btcsuite/btcd/btcutil v1.1.5 // indirect - github.com/cockroachdb/apd/v3 v3.2.1 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect - github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 // indirect - github.com/gnoswap-labs/gno v0.0.4 // indirect - github.com/gorilla/websocket v1.5.1 // indirect - github.com/jaekwon/testify v1.6.1 // indirect - github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/peterbourgon/ff/v3 v3.4.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v1.9.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect - golang.org/x/mod v0.16.0 // indirect - golang.org/x/net v0.22.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/term v0.18.0 // indirect - golang.org/x/tools v0.19.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/go.sum b/go.sum deleted file mode 100644 index c5b555c1..00000000 --- a/go.sum +++ /dev/null @@ -1,140 +0,0 @@ -github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= -github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= -github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= -github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= -github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= -github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= -github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= -github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8= -github.com/btcsuite/btcd/btcutil v1.1.5/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= -github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= -github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/cockroachdb/apd/v3 v3.2.1 h1:U+8j7t0axsIgvQUqthuNm82HIrYXodOV2iWLWtEaIwg= -github.com/cockroachdb/apd/v3 v3.2.1/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 h1:GKvsK3oLWG9B1GL7WP/VqwM6C92j5tIvB844oggL9Lk= -github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216/go.mod h1:xJhtEL7ahjM1WJipt89gel8tHzfIl/LyMY+lCYh38d8= -github.com/gnoswap-labs/gno v0.0.4 h1:9OJska9VFBQkB1z4hAIMH/iVZI76UlN+/OAAUNSYRgk= -github.com/gnoswap-labs/gno v0.0.4/go.mod h1:zlcOpivJM4Sw2YUY7n+SFPNQjtT5p6+p6H6SWwZw/Pg= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/jaekwon/testify v1.6.1 h1:4AtAJcR9GzXN5W4DdY7ie74iCPiJV1JJUJL90t2ZUyw= -github.com/jaekwon/testify v1.6.1/go.mod h1:Oun0RXIHI7osufabQ60i4Lqkj0GXLbqI1I7kgzBNm1U= -github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= -github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/peterbourgon/ff/v3 v3.4.0 h1:QBvM/rizZM1cB0p0lGMdmR7HxZeI/ZrBWB4DqLkMUBc= -github.com/peterbourgon/ff/v3 v3.4.0/go.mod h1:zjJVUhx+twciwfDl0zBcFzl4dW8axCRyXE/eKY9RztQ= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= -golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= -golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= -golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pool/_TEST_/_TEST_0_INIT_TOKEN_REGISTER_test.gno b/pool/_TEST_/__TEST_0_INIT_TOKEN_REGISTER_test.gno similarity index 100% rename from pool/_TEST_/_TEST_0_INIT_TOKEN_REGISTER_test.gno rename to pool/_TEST_/__TEST_0_INIT_TOKEN_REGISTER_test.gno diff --git a/pool/_TEST_/_TEST_0_INIT_VARIABLE_AND_HELPER_test.gno b/pool/_TEST_/__TEST_0_INIT_VARIABLE_AND_HELPER_test.gno similarity index 89% rename from pool/_TEST_/_TEST_0_INIT_VARIABLE_AND_HELPER_test.gno rename to pool/_TEST_/__TEST_0_INIT_VARIABLE_AND_HELPER_test.gno index 7e6df846..18a4a5e0 100644 --- a/pool/_TEST_/_TEST_0_INIT_VARIABLE_AND_HELPER_test.gno +++ b/pool/_TEST_/__TEST_0_INIT_VARIABLE_AND_HELPER_test.gno @@ -26,6 +26,13 @@ var ( maxApprove uint64 = 18446744073709551615 ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) +) + /* HELPER */ func shouldEQ(t *testing.T, got, expected interface{}) { if got != expected { diff --git a/pool/_TEST_/z0_rpc_filetest.gno b/pool/_TEST_/__TEST_Z_z0_rpc_filetest.gnoA similarity index 94% rename from pool/_TEST_/z0_rpc_filetest.gno rename to pool/_TEST_/__TEST_Z_z0_rpc_filetest.gnoA index 14c95386..de9d506f 100644 --- a/pool/_TEST_/z0_rpc_filetest.gno +++ b/pool/_TEST_/__TEST_Z_z0_rpc_filetest.gnoA @@ -40,6 +40,12 @@ var ( t *testing.T ) +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -149,10 +155,12 @@ func (GNSToken) Approve() func(spender pusers.AddressOrName, amount uint64) { } func init() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/bar", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/foo", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -173,7 +181,7 @@ func main() { } func createFooBarPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -186,7 +194,7 @@ func createFooBarPool() { } func createBarBazPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -199,12 +207,12 @@ func createBarBazPool() { } func mintFooBar() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) - //std.TestSetPrevRealm(consts.POSITION_PATH) + //std.TestSetRealm(posRealm) //std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Mint( barPath, @@ -224,12 +232,12 @@ func mintFooBar() { } func mintBarBaz() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) - //std.TestSetPrevRealm(consts.POSITION_PATH) + //std.TestSetRealm(posRealm) //std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Mint( barPath, diff --git a/pool/_TEST_/z1_single_lp_filetest.gno b/pool/_TEST_/__TEST_Z_z1_single_lp_filetest.gnoA similarity index 96% rename from pool/_TEST_/z1_single_lp_filetest.gno rename to pool/_TEST_/__TEST_Z_z1_single_lp_filetest.gnoA index 09297777..862abadd 100644 --- a/pool/_TEST_/z1_single_lp_filetest.gno +++ b/pool/_TEST_/__TEST_Z_z1_single_lp_filetest.gnoA @@ -40,6 +40,12 @@ var ( t *testing.T ) +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -165,10 +171,12 @@ func ugnotBalanceOf(addr std.Address) uint64 { } func init() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -191,7 +199,7 @@ func main() { } func createBarFooPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -203,12 +211,12 @@ func createBarFooPool() { std.TestSkipHeights(1) } func mint() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Mint( fooPath, @@ -287,7 +295,7 @@ func mint() { } } func burn() { - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) b11, b12 := pl.Burn(barPath, fooPath, fee500, 9000, 11000, "1000") @@ -327,7 +335,7 @@ func burn() { } } func collect() { - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) // withdraw all token before test `Collect` @@ -389,11 +397,11 @@ func swap() { panic("expected 0") } - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) pl.Mint(barPath, fooPath, fee500, consts.POSITION_ADDR.String(), 9000, 11000, "2000000") - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) { amount0, amount1 := pl.Swap( @@ -449,7 +457,7 @@ func collectProtocol() { std.TestSetOrigCaller(gsa) pl.SetFeeProtocol(6, 8) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) pl.Swap( barPath, @@ -462,7 +470,7 @@ func collectProtocol() { std.GetOrigCaller().String(), ) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) protocolFee0, protocolFee1 := pl.CollectProtocol(barPath, fooPath, fee500, gsa.String(), "100000", "100000") if protocolFee0 != "8" { panic(protocolFee0) diff --git a/pool/_TEST_/z2_native_swap_filetest.gno b/pool/_TEST_/__TEST_Z_z2_native_swap_filetest.gnoA similarity index 91% rename from pool/_TEST_/z2_native_swap_filetest.gno rename to pool/_TEST_/__TEST_Z_z2_native_swap_filetest.gnoA index 74c48615..9a5a110e 100644 --- a/pool/_TEST_/z2_native_swap_filetest.gno +++ b/pool/_TEST_/__TEST_Z_z2_native_swap_filetest.gnoA @@ -42,6 +42,12 @@ var ( t *testing.T ) +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -168,7 +174,9 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -187,7 +195,7 @@ func main() { } func createFooWUGNOT() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -207,22 +215,25 @@ func mint() { // prepare ugnot testBanker := std.GetBanker(std.BankerTypeRealmIssue) - testBanker.IssueCoin(gsa, "ugnot", 804_032) + + std.TestIssueCoins(gsa, std.Coins{{"ugnot", 804032}}) + // testBanker.IssueCoin(gsa, "ugnot", 804_032) // simulate transfer & decrase std.TestSetOrigSend(std.Coins{{"ugnot", 804_032}}, nil) - testBanker.RemoveCoin(std.GetOrigCaller(), "ugnot", 804_032) + std.TestSetOrigCaller(gsa) + // testBanker.RemoveCoin(gsa, "ugnot", 804_032) // TODO: HOW TO REMOVE // Deposit(wrap) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) wugnot.Deposit() - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), maxApprove) wugnot.Approve(a2u(consts.POOL_ADDR), maxApprove) // Mint - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) amount0, amount1 := pl.Mint( fooPath, consts.WRAPPED_WUGNOT, @@ -243,10 +254,10 @@ func mint() { func swapBuyNative() { pool := pl.GetPool(fooPath, consts.WRAPPED_WUGNOT, fee500) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), 10000) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( fooPath, // token0 @@ -266,10 +277,10 @@ func swapBuyNative() { func swapSellNative() { pool := pl.GetPool(fooPath, consts.WRAPPED_WUGNOT, fee500) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), 10000) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( // ugnot 10_000 > foo ?? fooPath, // token0 diff --git a/pool/_TEST_/z3_dryswap_and_swap_filetest.gno b/pool/_TEST_/__TEST_Z_z3_dryswap_and_swap_filetest.gnoA similarity index 95% rename from pool/_TEST_/z3_dryswap_and_swap_filetest.gno rename to pool/_TEST_/__TEST_Z_z3_dryswap_and_swap_filetest.gnoA index 49c5286a..6cc6ef27 100644 --- a/pool/_TEST_/z3_dryswap_and_swap_filetest.gno +++ b/pool/_TEST_/__TEST_Z_z3_dryswap_and_swap_filetest.gnoA @@ -42,6 +42,12 @@ var ( t *testing.T ) +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -167,10 +173,10 @@ func ugnotBalanceOf(addr std.Address) uint64 { } func init() { - std.TestSetPrevAddr(gsa) - // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -190,7 +196,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -203,7 +209,7 @@ func createPool() { } func drySwap_ZeroForOneTrue_AmountSpecified_Positive_16000() { - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) // no mint == no liquidity => swap will fail @@ -213,11 +219,11 @@ func drySwap_ZeroForOneTrue_AmountSpecified_Positive_16000() { } // not enough mint == swap will fail - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) pl.Mint(fooPath, barPath, fee500, consts.POSITION_ADDR.String(), -test_tickUpper, -test_tickLower, "10") _, _, ok = pl.DrySwap(fooPath, barPath, fee500, true, "16000", consts.MIN_PRICE) @@ -225,7 +231,7 @@ func drySwap_ZeroForOneTrue_AmountSpecified_Positive_16000() { panic("expected dry swap to fail #2") } - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) pl.Mint(fooPath, barPath, fee500, consts.POSITION_ADDR.String(), -test_tickUpper, -test_tickLower, "100000000000") // -11000 ~ -9000 // zeroForOne true diff --git a/pool/_TEST_/_TEST_pool_all_test.gnoA b/pool/_TEST_/__TEST_pool_all_test.gnoA similarity index 91% rename from pool/_TEST_/_TEST_pool_all_test.gnoA rename to pool/_TEST_/__TEST_pool_all_test.gnoA index 753f4382..56ba047b 100644 --- a/pool/_TEST_/_TEST_pool_all_test.gnoA +++ b/pool/_TEST_/__TEST_pool_all_test.gnoA @@ -23,7 +23,7 @@ var ( // 1. Create Foo:Bar Pool func TestCreateFooBarPool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -35,7 +35,7 @@ func TestCreateFooBarPool(t *testing.T) { // 2. Create Bar:Baz Pool func TestCreateBarBazPool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -47,13 +47,13 @@ func TestCreateBarBazPool(t *testing.T) { // 3. Mint Foo:Bar Liquidity by gsa func TestMintFooBarLiquidity(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(4) - std.TestSetPrevRealm(consts.POSITION_PATH) - std.TestSetOrigCaller(gsa) + std.TestSetRealm(posRealm) amount0, amount1 := Mint( barPath, fooPath, @@ -70,13 +70,13 @@ func TestMintFooBarLiquidity(t *testing.T) { // 4. Mint Bar:Baz Liquidity by gsa func TestMintBarBazLiquidity(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) - std.TestSetPrevRealm(consts.POSITION_PATH) - std.TestSetOrigCaller(gsa) + std.TestSetRealm(posRealm) amount0, amount1 := Mint( barPath, bazPath, diff --git a/pool/_TEST_/_TEST_pool_dryswap_and_swap_test.gnoA b/pool/_TEST_/__TEST_pool_dryswap_and_swap_test.gnoA similarity index 94% rename from pool/_TEST_/_TEST_pool_dryswap_and_swap_test.gnoA rename to pool/_TEST_/__TEST_pool_dryswap_and_swap_test.gnoA index 202eaaab..be916c0c 100644 --- a/pool/_TEST_/_TEST_pool_dryswap_and_swap_test.gnoA +++ b/pool/_TEST_/__TEST_pool_dryswap_and_swap_test.gnoA @@ -24,7 +24,7 @@ var ( func TestCreatePool(t *testing.T) { // call gns faucet to get creation fee - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) CreatePool(fooPath, barPath, fee500, sqrtPrice) @@ -33,7 +33,7 @@ func TestCreatePool(t *testing.T) { } func TestDrySwap_ZeroForOneTrue_AmountSpecified_Positive_16000(t *testing.T) { - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) // no mint == no liquidity => swap will fail @@ -41,19 +41,20 @@ func TestDrySwap_ZeroForOneTrue_AmountSpecified_Positive_16000(t *testing.T) { shouldEQ(t, ok, false) // not enough mint == swap will fail - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) Mint(fooPath, barPath, fee500, consts.POSITION_ADDR.String(), -tickUpper, -tickLower, "10") _, _, ok = DrySwap(fooPath, barPath, fee500, true, "16000", consts.MIN_PRICE) shouldEQ(t, ok, false) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) Mint(fooPath, barPath, fee500, consts.POSITION_ADDR.String(), -tickUpper, -tickLower, liquidityExpect) // -11000 ~ -9000 diff --git a/pool/_TEST_/_TEST_pool_multi_token_test.gnoA b/pool/_TEST_/__TEST_pool_multi_token_test.gnoA similarity index 95% rename from pool/_TEST_/_TEST_pool_multi_token_test.gnoA rename to pool/_TEST_/__TEST_pool_multi_token_test.gnoA index 02b9f9ba..554d8549 100644 --- a/pool/_TEST_/_TEST_pool_multi_token_test.gnoA +++ b/pool/_TEST_/__TEST_pool_multi_token_test.gnoA @@ -26,7 +26,7 @@ var ( // Create Foo:Bar Pool func TestCreateFooBarPool(t *testing.T) { // call gns faucet to get creation fee - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) @@ -38,7 +38,7 @@ func TestCreateFooBarPool(t *testing.T) { // Create Bar:Baz Pool func TestCreateBarBazPool(t *testing.T) { // call gns faucet to get creation fee - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) @@ -49,11 +49,11 @@ func TestCreateBarBazPool(t *testing.T) { // Mint Foo:Bar Liquidity by gsa func TestMintFooBarLiquidity(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := Mint( fooPath, @@ -70,11 +70,11 @@ func TestMintFooBarLiquidity(t *testing.T) { // Mint Bar:Baz Liquidity by gsa func TestMintBarBazLiquidity(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := Mint( barPath, @@ -97,10 +97,10 @@ func TestSwapFooBarFooToBar(t *testing.T) { oldPoolBar := balanceOfByRegisterCall(barPath, consts.POOL_ADDR) oldPoolFoo := balanceOfByRegisterCall(fooPath, consts.POOL_ADDR) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 16000) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) poolIn, poolOut := Swap( barPath, @@ -136,10 +136,10 @@ func TestSwapBarBazBarToBaz(t *testing.T) { oldPoolToken0Balance := balanceOfByRegisterCall(barPath, consts.POOL_ADDR) oldPoolBazBalance := balanceOfByRegisterCall(bazPath, consts.POOL_ADDR) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 16000) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) poolIn, poolOut := Swap( barPath, @@ -169,7 +169,7 @@ func TestSwapBarBazBarToBaz(t *testing.T) { // Collect Foo:Bar Fees by gsa func TestCollectFooBarFees(t *testing.T) { - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) oldTest1Token1Balance := balanceOfByRegisterCall(fooPath, gsa) @@ -207,7 +207,7 @@ func TestCollectFooBarFees(t *testing.T) { // Collect Bar:Baz Fees by gsa func TestCollectBarBazFees(t *testing.T) { - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) oldTest1Token0Balance := balanceOfByRegisterCall(barPath, gsa) @@ -246,7 +246,7 @@ func TestCollectBarBazFees(t *testing.T) { // Burn Foo:Bar Liquidity by gsa func TestBurnFooBarLiquidity(t *testing.T) { std.TestSetOrigCaller(gsa) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) pool := GetPool(fooPath, barPath, fee500) poolOldLiquidity := pool.PoolGetLiquidity() @@ -271,7 +271,7 @@ func TestBurnFooBarLiquidity(t *testing.T) { // Burn Bar:Baz Liquidity by gsa func TestBurnBarBazLiquidity(t *testing.T) { std.TestSetOrigCaller(gsa) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) pool := GetPool(barPath, bazPath, fee500) poolOldLiquidity := pool.PoolGetLiquidity() @@ -296,7 +296,7 @@ func TestBurnBarBazLiquidity(t *testing.T) { // Collect Foo:Bar burned Liquidity by gsa func TestCollectFooBarLiquidity(t *testing.T) { std.TestSetOrigCaller(gsa) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) oldTest1Token1Balance := balanceOfByRegisterCall(fooPath, gsa) oldTest1Token0Balance := balanceOfByRegisterCall(barPath, gsa) @@ -331,7 +331,7 @@ func TestCollectFooBarLiquidity(t *testing.T) { // Collect Bar:Baz burned Liquidity by gsa func TestCollectBarBazLiquidity(t *testing.T) { std.TestSetOrigCaller(gsa) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) oldTest1Token0Balance := balanceOfByRegisterCall(barPath, gsa) oldgsaBazBalance := balanceOfByRegisterCall(bazPath, gsa) diff --git a/pool/_TEST_/_TEST_pool_native_swap_test.gnoA b/pool/_TEST_/__TEST_pool_native_swap_test.gnoA similarity index 94% rename from pool/_TEST_/_TEST_pool_native_swap_test.gnoA rename to pool/_TEST_/__TEST_pool_native_swap_test.gnoA index c2b88bda..7e563e07 100644 --- a/pool/_TEST_/_TEST_pool_native_swap_test.gnoA +++ b/pool/_TEST_/__TEST_pool_native_swap_test.gnoA @@ -20,7 +20,7 @@ var ( // 1. Init & Create Pool func TestPoolInitCreatePool(t *testing.T) { // call gns faucet to get creation fee - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) CreatePool(fooPath, consts.WRAPPED_WUGNOT, fee500, "130621891405341611593710811006") // x2.7 @@ -43,15 +43,15 @@ func TestMint(t *testing.T) { testBanker.RemoveCoin(std.GetOrigCaller(), "ugnot", 804_032) // Deposit(wrap) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) wugnot.Deposit() - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), 295802) wugnot.Approve(a2u(consts.POOL_ADDR), 804032) // Mint - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) amount0, amount1 := Mint( fooPath, consts.WRAPPED_WUGNOT, @@ -74,10 +74,10 @@ func TestSwapBuyNative(t *testing.T) { shouldEQ(t, gsaOldT0Bal, 99999999704198) // foo shouldEQ(t, gsaOldT1Bal, 0) // wugnot - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), 10000) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := Swap( fooPath, // token0 @@ -108,10 +108,10 @@ func TestSwapSellNative(t *testing.T) { shouldEQ(t, gsaOldT0Bal, 99999999694198) // foo shouldEQ(t, gsaOldT1Bal, 27123) // wugnot - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) wugnot.Approve(a2u(consts.POOL_ADDR), 27123) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := Swap( // ugnot 10_000 > foo ?? fooPath, // token0 diff --git a/pool/_TEST_/_TEST_pool_single_lp_test.gnoA b/pool/_TEST_/__TEST_pool_single_lp_test.gnoA similarity index 98% rename from pool/_TEST_/_TEST_pool_single_lp_test.gnoA rename to pool/_TEST_/__TEST_pool_single_lp_test.gnoA index 7d291c5a..64bba3cb 100644 --- a/pool/_TEST_/_TEST_pool_single_lp_test.gnoA +++ b/pool/_TEST_/__TEST_pool_single_lp_test.gnoA @@ -29,7 +29,7 @@ var ( // 1. reate Pool using Factory Contract by Gnoswap Admin func TestInitCreatePool(t *testing.T) { // call gns faucet to get creation fee - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) CreatePool(barPath, fooPath, fee500, "130621891405341611593710811006") // x2.7 @@ -38,12 +38,12 @@ func TestInitCreatePool(t *testing.T) { // 2. Mint by gsa func TestMint(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := Mint( fooPath, @@ -110,7 +110,7 @@ func TestMint(t *testing.T) { // 3. Burn by gsa func TestBurn(t *testing.T) { - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) b11, b12 := Burn(barPath, fooPath, fee500, test_tickLower, test_tickUpper, test_liquidityExpectStr) @@ -141,7 +141,7 @@ func TestBurn(t *testing.T) { // 4. Collect func TestCollect(t *testing.T) { - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) // withdraw all token before test `Collect` @@ -193,12 +193,12 @@ func TestSwap(t *testing.T) { test_liquidity := pool.PoolGetLiquidity() shouldEQ(t, test_liquidity.ToString(), "0") - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) Mint(barPath, fooPath, fee500, consts.POSITION_ADDR.String(), test_tickLower, test_tickUpper, new(u256.Uint).Mul(test_liquidityExpect256, u256.NewUint(20000)).ToString()) // Swap several times - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) test_price := consts.MIN_PRICE { @@ -344,7 +344,7 @@ func TestCollectProtocol(t *testing.T) { std.TestSetOrigCaller(gsa) { - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) Swap(barPath, fooPath, fee500, gsa.String(), true, "200000", consts.MIN_PRICE, std.GetOrigCaller().String()) // swap token0 -> token1 => fee only in token0 // --- event: {gno.land/r/demo/pool Swap GNOSWAP [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm gno.land/r/demo/router} {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500} {p_zeroForOne true} {p_amountSpecified 200000} {p_sqrtPriceLimitX96 4295128740} {p_payer g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {p_recipient g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {amount0 200000} {amount1 -533667} {protocol_fee0 16} {protocol_fee1 0} {swap_fee 84}]} @@ -352,7 +352,7 @@ func TestCollectProtocol(t *testing.T) { gsaOldToken0Bal := balanceOfByRegisterCall(pool.token0Path, gsa) gsaOldToken1Bal := balanceOfByRegisterCall(pool.token1Path, gsa) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) amount0, amount1 := CollectProtocol(barPath, fooPath, fee500, gsa.String(), "100000", "100000") // --- event: {GNOSWAP gno.land/r/demo/pool CollectProtocol [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500} {p_recipient g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {amount0 15} {amount1 0}]} diff --git a/pool/_TEST_/_TEST_pool_test.gnoA b/pool/_TEST_/__TEST_pool_test.gnoA similarity index 92% rename from pool/_TEST_/_TEST_pool_test.gnoA rename to pool/_TEST_/__TEST_pool_test.gnoA index 29fa6836..a624fc42 100644 --- a/pool/_TEST_/_TEST_pool_test.gnoA +++ b/pool/_TEST_/__TEST_pool_test.gnoA @@ -24,7 +24,7 @@ var ( // 1. Create Foo:Bar Pool func TestCreateFooBarPool(t *testing.T) { // call gns faucet to get creation fee - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) std.TestSkipHeights(5) @@ -41,8 +41,8 @@ func TestCreateFooBarPool(t *testing.T) { // 2. Create Bar:Baz Pool func TestCreateBarBazPool(t *testing.T) { // call gns faucet to get creation fee - std.TestSetPrevAddr(gsa) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetRealm(gsaRealm) std.TestSkipHeights(5) @@ -58,12 +58,12 @@ func TestCreateBarBazPool(t *testing.T) { // 3. Mint Foo:Bar Liquidity by gsa func TestMintFooBarLiquidity(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(4) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := Mint( barPath, @@ -81,12 +81,12 @@ func TestMintFooBarLiquidity(t *testing.T) { // 4. Mint Bar:Baz Liquidity by gsa func TestMintBarBazLiquidity(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) - std.TestSetPrevRealm(consts.POSITION_PATH) + std.TestSetRealm(posRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := Mint( barPath, diff --git a/position/_TEST_/__TEST_0_INIT_VARS_HELPERS_test.gno b/position/_TEST_/__TEST_0_INIT_VARS_HELPERS_test.gno index a752489f..f53cf7ed 100644 --- a/position/_TEST_/__TEST_0_INIT_VARS_HELPERS_test.gno +++ b/position/_TEST_/__TEST_0_INIT_VARS_HELPERS_test.gno @@ -31,6 +31,14 @@ var ( max_timeout int64 = 9999999999 ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + /* HELPER */ func shouldEQ(t *testing.T, got, expected interface{}) { if got != expected { diff --git a/position/_TEST_/__TEST_Z_z1_position_filetest.gnoA b/position/_TEST_/__TEST_Z_z1_position_filetest.gnoA index 587c1ac0..496c2ead 100644 --- a/position/_TEST_/__TEST_Z_z1_position_filetest.gnoA +++ b/position/_TEST_/__TEST_Z_z1_position_filetest.gnoA @@ -42,6 +42,14 @@ var ( t *testing.T ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -167,10 +175,12 @@ func ugnotBalanceOf(addr std.Address) uint64 { } func init() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -192,7 +202,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -205,12 +215,12 @@ func createPool() { } func mint01InRange() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 18394892) foo.Approve(a2u(consts.POOL_ADDR), 50000000) - std.TestSetPrevAddr(gsa) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(gsaRealm) + std.TestSetRealm(stkRealm) tokenId, liquidity, amount0, amount1 := pn.Mint( barPath, fooPath, @@ -236,12 +246,12 @@ func mint01InRange() { } func mint02LowerRange() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 0) foo.Approve(a2u(consts.POOL_ADDR), 50000000) - std.TestSetPrevAddr(gsa) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(gsaRealm) + std.TestSetRealm(stkRealm) tokenId, liquidity, amount0, amount1 := pn.Mint( barPath, fooPath, @@ -267,12 +277,12 @@ func mint02LowerRange() { } func mint03UpperRange() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 50000000) foo.Approve(a2u(consts.POOL_ADDR), 0) - std.TestSetPrevAddr(gsa) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(gsaRealm) + std.TestSetRealm(stkRealm) tokenId, liquidity, amount0, amount1 := pn.Mint( barPath, fooPath, @@ -298,10 +308,10 @@ func mint03UpperRange() { } func swap() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 1234567) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( barPath, @@ -322,7 +332,7 @@ func swap() { } func collectFeeAfterSwap() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE @@ -340,7 +350,7 @@ func collectFeeAfterSwap() { } func decreaseLiquidityUpperPosition() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) tokenId, liquidity, fee0, fee1, amount0, amount1, poolPath := pn.DecreaseLiquidity(uint64(3), 100, "0", "0", max_timeout, false) if tokenId != 3 { diff --git a/position/_TEST_/__TEST_Z_z2_position_increase_decrease_filetest.gnoA b/position/_TEST_/__TEST_Z_z2_position_increase_decrease_filetest.gnoA index 0064d551..09269aed 100644 --- a/position/_TEST_/__TEST_Z_z2_position_increase_decrease_filetest.gnoA +++ b/position/_TEST_/__TEST_Z_z2_position_increase_decrease_filetest.gnoA @@ -42,6 +42,13 @@ var ( t *testing.T ) +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -166,10 +173,12 @@ func ugnotBalanceOf(addr std.Address) uint64 { return uint64(coins.AmountOf("ugnot")) } func init() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -191,7 +200,7 @@ func main() { func createPool() { // call gns faucet to get creation fee - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -204,12 +213,12 @@ func createPool() { } func mint() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 18394892) foo.Approve(a2u(consts.POOL_ADDR), 50000000) - std.TestSetPrevAddr(gsa) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(gsaRealm) + std.TestSetRealm(stkRealm) tokenId, liquidity, amount0, amount1 := pn.Mint( barPath, fooPath, @@ -235,7 +244,7 @@ func mint() { } func increase() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 3678979) foo.Approve(a2u(consts.POOL_ADDR), 10000000) @@ -269,7 +278,7 @@ func increase() { } func decreasePartial() { - std.TestSetPrevRealm("") + std.TestSetOrigCaller(gsa) pool := pl.GetPool(barPath, fooPath, fee500) @@ -306,10 +315,10 @@ func decreasePartial() { } func swap() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 1_234_567) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( barPath, @@ -324,7 +333,7 @@ func swap() { } func decreaseFull() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // protocol fee approval bar.Approve(a2u(consts.POOL_ADDR), 10000000) diff --git a/position/_TEST_/__TEST_Z_z3_position_two_position_used_single_swap_filetest.gnoA b/position/_TEST_/__TEST_Z_z3_position_two_position_used_single_swap_filetest.gnoA index 0cf5778d..63a6e2db 100644 --- a/position/_TEST_/__TEST_Z_z3_position_two_position_used_single_swap_filetest.gnoA +++ b/position/_TEST_/__TEST_Z_z3_position_two_position_used_single_swap_filetest.gnoA @@ -42,6 +42,13 @@ var ( t *testing.T ) +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -168,7 +175,9 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -190,7 +199,7 @@ func main() { func createPool() { // call gns faucet to get creation fee - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -203,12 +212,12 @@ func createPool() { } func mint01Wide() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 18394892) foo.Approve(a2u(consts.POOL_ADDR), 50000000) - std.TestSetPrevAddr(gsa) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(gsaRealm) + std.TestSetRealm(stkRealm) tokenId, liquidity, amount0, amount1 := pn.Mint( barPath, fooPath, @@ -237,12 +246,12 @@ func mint01Wide() { } func mint02Tight() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 18394892) foo.Approve(a2u(consts.POOL_ADDR), 50000000) - std.TestSetPrevAddr(gsa) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(gsaRealm) + std.TestSetRealm(stkRealm) tokenId, liquidity, amount0, amount1 := pn.Mint( barPath, fooPath, @@ -271,10 +280,10 @@ func mint02Tight() { } func swap() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 1_234_567) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( barPath, @@ -289,7 +298,7 @@ func swap() { } func collect01() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE @@ -303,7 +312,7 @@ func collect01() { } func collect02() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE diff --git a/position/_TEST_/__TEST_position_api_test.gnoA b/position/_TEST_/__TEST_position_api_test.gnoA index 023fc12f..fe09863e 100644 --- a/position/_TEST_/__TEST_position_api_test.gnoA +++ b/position/_TEST_/__TEST_position_api_test.gnoA @@ -18,7 +18,7 @@ import ( ) func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(fooPath, barPath, fee500, "130621891405341611593710811006") // tick = 10000 @@ -29,7 +29,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestMintFooBar(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -45,7 +45,7 @@ func TestMintFooBar(t *testing.T) { } func TestMintBazQux(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -78,7 +78,7 @@ func TestApiGetPositionsUnclaimedFee(t *testing.T) { } func TestSwap(t *testing.T) { - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) pl.Swap( fooPath, diff --git a/position/_TEST_/__TEST_position_full_test.gnoA b/position/_TEST_/__TEST_position_full_test.gnoA index 08ecf20f..5cca8156 100644 --- a/position/_TEST_/__TEST_position_full_test.gnoA +++ b/position/_TEST_/__TEST_position_full_test.gnoA @@ -16,7 +16,7 @@ import ( ) func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(barPath, fooPath, fee500, common.TickMathGetSqrtRatioAtTick(1).ToString()) @@ -24,7 +24,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestMintPositionFullInRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -46,7 +46,7 @@ func TestMintPositionFullInRange(t *testing.T) { } func TestIncreaseLiquidity(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -62,7 +62,7 @@ func TestIncreaseLiquidity(t *testing.T) { } func TestDecreaseLiquidity(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -81,7 +81,7 @@ func TestDecreaseLiquidity(t *testing.T) { } func TestCollectFee(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) diff --git a/position/_TEST_/__TEST_position_increase_decrease_test.gnoA b/position/_TEST_/__TEST_position_increase_decrease_test.gnoA index a8ef550f..eab325a2 100644 --- a/position/_TEST_/__TEST_position_increase_decrease_test.gnoA +++ b/position/_TEST_/__TEST_position_increase_decrease_test.gnoA @@ -16,7 +16,7 @@ import ( // 1. Create Pool func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(barPath, fooPath, fee500, common.TickMathGetSqrtRatioAtTick(10000).ToString()) // x2.71814592682522526700950038502924144268035888671875 @@ -24,7 +24,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestMintPosition(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 18394892) foo.Approve(a2u(consts.POOL_ADDR), 50000000) @@ -49,7 +49,7 @@ func TestMintPosition(t *testing.T) { } func TestIncreaseLiquidity(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 3678979) foo.Approve(a2u(consts.POOL_ADDR), 10000000) @@ -75,7 +75,7 @@ func TestIncreaseLiquidity(t *testing.T) { } func TestCollectFeeBeforeSwap(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) tokenId, fee0, fee1, poolPath := CollectFee(1) // --- event: {GNOSWAP gno.land/r/demo/pool HandleWithdrawalFee [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm gno.land/r/demo/position} {p_tokenId 1} {p_token0Path gno.land/r/demo/bar} {p_token1Path gno.land/r/demo/foo} {fee0Amount 0} {fee1Amount 0}]} @@ -88,10 +88,10 @@ func TestCollectFeeBeforeSwap(t *testing.T) { } func TestSwap(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 1_234_567) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( barPath, @@ -107,7 +107,7 @@ func TestSwap(t *testing.T) { } func TestCollectFeeAfterSwap(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -123,7 +123,7 @@ func TestCollectFeeAfterSwap(t *testing.T) { } func TestCollectFee2(t *testing.T) { - std.TestSetPrevRealm("") + std.TestSetOrigCaller(gsa) tokenId, fee0, fee1, poolPath := CollectFee(1) @@ -141,7 +141,7 @@ func TestCollectFee2(t *testing.T) { } func TestSwap2(t *testing.T) { - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( barPath, @@ -156,7 +156,7 @@ func TestSwap2(t *testing.T) { // --- event: {GNOSWAP gno.land/r/demo/pool Swap [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm gno.land/r/demo/router} {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500} {p_zeroForOne true} {p_amountSpecified 1000000} {p_sqrtPriceLimitX96 4295128740} {p_payer g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {p_recipient g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {amount0 1000000} {amount1 -2676640} {protocol_fee0 0} {protocol_fee1 0} {swap_fee 500}]} // UNCLAIMED_FEE - std.TestSetPrevRealm("") + std.TestSetOrigCaller(gsa) oldFee0, oldFee1 := unclaimedFee(uint64(1)) @@ -174,7 +174,7 @@ func TestSwap2(t *testing.T) { } func TestDecreaseLiquidity(t *testing.T) { - std.TestSetPrevRealm("") + std.TestSetOrigCaller(gsa) oldLiquidity := getPoolFromLpTokenId(uint64(1)).PoolGetLiquidity() diff --git a/position/_TEST_/__TEST_position_mint_swap_burn_left_B_test.gnoA b/position/_TEST_/__TEST_position_mint_swap_burn_left_B_test.gnoA index 92681d5e..6ec26757 100644 --- a/position/_TEST_/__TEST_position_mint_swap_burn_left_B_test.gnoA +++ b/position/_TEST_/__TEST_position_mint_swap_burn_left_B_test.gnoA @@ -16,7 +16,7 @@ import ( ) func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(oblPath, quxPath, fee3000, "177025116846713535491812780880") // tick = 16080, x.5 @@ -31,7 +31,7 @@ func TestPoolBalanceInit(t *testing.T) { } func TestMintPosition01InRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -56,11 +56,11 @@ func TestMintPosition01InRange(t *testing.T) { } func TestSwap1(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -78,11 +78,11 @@ func TestSwap1(t *testing.T) { } func TestSwap2(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -100,11 +100,11 @@ func TestSwap2(t *testing.T) { } func TestSwap3(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -122,11 +122,11 @@ func TestSwap3(t *testing.T) { } func TestSwap4(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -144,11 +144,11 @@ func TestSwap4(t *testing.T) { } func TestSwap5(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -166,11 +166,11 @@ func TestSwap5(t *testing.T) { } func TestSwap6(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -188,11 +188,11 @@ func TestSwap6(t *testing.T) { } func TestSwap7(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -210,11 +210,11 @@ func TestSwap7(t *testing.T) { } func TestSwap8(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -232,11 +232,11 @@ func TestSwap8(t *testing.T) { } func TestSwap9(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -254,11 +254,11 @@ func TestSwap9(t *testing.T) { } func TestSwap10(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -276,11 +276,11 @@ func TestSwap10(t *testing.T) { } func TestSwap11(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -298,11 +298,11 @@ func TestSwap11(t *testing.T) { } func TestSwap12(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -336,7 +336,7 @@ func TestCollectFee(t *testing.T) { } func TestDecreaseAllPos01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) diff --git a/position/_TEST_/__TEST_position_mint_swap_burn_left_G_test.gnoA b/position/_TEST_/__TEST_position_mint_swap_burn_left_G_test.gnoA index 85ade736..ffbe124d 100644 --- a/position/_TEST_/__TEST_position_mint_swap_burn_left_G_test.gnoA +++ b/position/_TEST_/__TEST_position_mint_swap_burn_left_G_test.gnoA @@ -16,7 +16,7 @@ import ( ) func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(barPath, fooPath, fee500, "130621891405341611593710811006") // tick = 10000 @@ -31,7 +31,7 @@ func TestPoolBalanceInit(t *testing.T) { } func TestMintPosition01InRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -64,7 +64,7 @@ func TestPoolBalanceMint01(t *testing.T) { } func TestMintPosition02InRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -117,10 +117,10 @@ func TestSwap1(t *testing.T) { // token0: 22073871 // token1: 60000000 - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 1234567) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( barPath, @@ -160,10 +160,10 @@ func TestSwap2(t *testing.T) { // token0: 23308438 // token1: 56661277 - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( barPath, diff --git a/position/_TEST_/__TEST_position_mint_swap_owed_test.gnoA b/position/_TEST_/__TEST_position_mint_swap_owed_test.gnoA index 9d461309..170fbeaf 100644 --- a/position/_TEST_/__TEST_position_mint_swap_owed_test.gnoA +++ b/position/_TEST_/__TEST_position_mint_swap_owed_test.gnoA @@ -16,7 +16,7 @@ import ( ) func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(oblPath, "gno.land/r/demo/usdc", fee3000, "79228162514264337593543950336") @@ -31,7 +31,7 @@ func TestPoolBalanceInit(t *testing.T) { } func TestMintPosition01InRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -56,7 +56,7 @@ func TestMintPosition01InRange(t *testing.T) { } func TestMintPosition02InRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -83,11 +83,11 @@ func TestMintPosition02InRange(t *testing.T) { } func TestSwap1(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -107,11 +107,11 @@ func TestSwap1(t *testing.T) { } func TestSwap2(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -141,11 +141,11 @@ func TestCollectFee(t *testing.T) { } func TestSwap3(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -165,7 +165,7 @@ func TestSwap3(t *testing.T) { } func TestDecreaseHalfPos01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -190,7 +190,7 @@ func TestDecreaseHalfPos01(t *testing.T) { } func TestDecreaseAllPos01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -216,11 +216,11 @@ func TestDecreaseAllPos01(t *testing.T) { /* func TestSwap2(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -238,11 +238,11 @@ func TestSwap2(t *testing.T) { } func TestSwap3(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -260,11 +260,11 @@ func TestSwap3(t *testing.T) { } func TestSwap4(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -282,11 +282,11 @@ func TestSwap4(t *testing.T) { } func TestSwap5(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -304,11 +304,11 @@ func TestSwap5(t *testing.T) { } func TestSwap6(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -326,11 +326,11 @@ func TestSwap6(t *testing.T) { } func TestSwap7(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -348,11 +348,11 @@ func TestSwap7(t *testing.T) { } func TestSwap8(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -370,11 +370,11 @@ func TestSwap8(t *testing.T) { } func TestSwap9(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -392,11 +392,11 @@ func TestSwap9(t *testing.T) { } func TestSwap10(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -414,11 +414,11 @@ func TestSwap10(t *testing.T) { } func TestSwap11(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -436,11 +436,11 @@ func TestSwap11(t *testing.T) { } func TestSwap12(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( oblPath, @@ -473,7 +473,7 @@ func TestCollectFee(t *testing.T) { } func TestDecreaseAllPos01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) usdc.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) obl.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) diff --git a/position/_TEST_/__TEST_position_native_increase_decrease_test.gnoA b/position/_TEST_/__TEST_position_native_increase_decrease_test.gnoA index 5c8a7d07..5cf0e0b4 100644 --- a/position/_TEST_/__TEST_position_native_increase_decrease_test.gnoA +++ b/position/_TEST_/__TEST_position_native_increase_decrease_test.gnoA @@ -15,7 +15,7 @@ import ( // 1. Create Pool func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(consts.GNS_PATH, consts.GNOT, fee500, common.TickMathGetSqrtRatioAtTick(10000).ToString()) // x2.71814592682522526700950038502924144268035888671875 @@ -23,7 +23,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestMintPosition(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) wugnot.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -80,7 +80,7 @@ func TestMintPosition(t *testing.T) { } func TestIncreaseLiquidity(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) wugnot.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -131,7 +131,7 @@ func TestIncreaseLiquidity(t *testing.T) { } func TestDecreaseLiquidityWrapped(t *testing.T) { - std.TestSetPrevRealm("") + std.TestSetOrigCaller(gsa) oldLiquidity := getPoolFromLpTokenId(uint64(1)).PoolGetLiquidity() @@ -174,7 +174,7 @@ func TestDecreaseLiquidityWrapped(t *testing.T) { } func TestDecreaseLiquidityUnwrapped(t *testing.T) { - std.TestSetPrevRealm("") + std.TestSetOrigCaller(gsa) oldLiquidity := getPoolFromLpTokenId(uint64(1)).PoolGetLiquidity() diff --git a/position/_TEST_/__TEST_position_native_unclaimed_fee_test.gnoA b/position/_TEST_/__TEST_position_native_unclaimed_fee_test.gnoA index 1172d513..f22d7500 100644 --- a/position/_TEST_/__TEST_position_native_unclaimed_fee_test.gnoA +++ b/position/_TEST_/__TEST_position_native_unclaimed_fee_test.gnoA @@ -14,7 +14,7 @@ import ( ) func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(consts.GNS_PATH, consts.GNOT, fee500, common.TickMathGetSqrtRatioAtTick(10000).ToString()) // x2.71814592682522526700950038502924144268035888671875 @@ -22,7 +22,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestMintPosition(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) wugnot.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -84,10 +84,10 @@ func TestUnclaimedFee0(t *testing.T) { // GNS > GNOT func TestSwapSellGnsBuyGnot(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), 1234567) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( consts.GNS_PATH, @@ -114,10 +114,10 @@ func TestUnclaimedFee1(t *testing.T) { // GNOT > GNS func TestSwapSellGnotBuyGns(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), 123456) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( consts.GNS_PATH, @@ -149,7 +149,7 @@ func TestCollectFeeAfterSwap(t *testing.T) { oldUgnot := ugnotBalanceOf(gsa) shouldEQ(t, oldUgnot, 5) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE wugnot.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE diff --git a/position/_TEST_/__TEST_position_pool_and_position_balance_diff_test.gnoA b/position/_TEST_/__TEST_position_pool_and_position_balance_diff_test.gnoA index 73e409ae..181d4030 100644 --- a/position/_TEST_/__TEST_position_pool_and_position_balance_diff_test.gnoA +++ b/position/_TEST_/__TEST_position_pool_and_position_balance_diff_test.gnoA @@ -17,7 +17,7 @@ import ( ) func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(barPath, fooPath, fee500, "130621891405341611593710811006") // tick = 10000 @@ -28,7 +28,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestMintPosition01InRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 18394892) foo.Approve(a2u(consts.POOL_ADDR), 50000000) @@ -71,10 +71,10 @@ func TestMintPosition01InRange(t *testing.T) { } func TestSwap(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 1234567) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( barPath, @@ -116,7 +116,7 @@ func TestSwap(t *testing.T) { } func TestCollectFeeAfterSwap(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE diff --git a/position/_TEST_/__TEST_position_test_two_position_used_single_swap_test.gnoA b/position/_TEST_/__TEST_position_test_two_position_used_single_swap_test.gnoA index 3233ea8c..e428c1a8 100644 --- a/position/_TEST_/__TEST_position_test_two_position_used_single_swap_test.gnoA +++ b/position/_TEST_/__TEST_position_test_two_position_used_single_swap_test.gnoA @@ -14,7 +14,7 @@ import ( ) func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(barPath, fooPath, fee500, "130621891405341611593710811006") // tick = 10000 @@ -22,7 +22,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestMintPosition01WideInRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 18394892) foo.Approve(a2u(consts.POOL_ADDR), 50000000) @@ -49,7 +49,7 @@ func TestMintPosition01WideInRange(t *testing.T) { } func TestMintPositionTightInRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 18394892) foo.Approve(a2u(consts.POOL_ADDR), 50000000) @@ -98,10 +98,10 @@ func TestCollectFeeBeforeSwapPos2(t *testing.T) { } func TestSwap(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 1234567) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( barPath, @@ -119,7 +119,7 @@ func TestSwap(t *testing.T) { // FYI, IF POSITION 2 DOESN'T EXIST, POSITION 1 WILL EARN '617' as fee func TestCollectFeeAfterSwapPos1(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE diff --git a/position/_TEST_/__TEST_position_unclaimed_fee_test.gnoA b/position/_TEST_/__TEST_position_unclaimed_fee_test.gnoA index 9046cd07..e9f31a4f 100644 --- a/position/_TEST_/__TEST_position_unclaimed_fee_test.gnoA +++ b/position/_TEST_/__TEST_position_unclaimed_fee_test.gnoA @@ -19,7 +19,7 @@ import ( ) func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(barPath, fooPath, fee500, "130621891405341611593710811006") // tick = 10000 @@ -28,7 +28,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestMintPosition01InRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 18394892) foo.Approve(a2u(consts.POOL_ADDR), 50000000) @@ -54,7 +54,7 @@ func TestMintPosition01InRange(t *testing.T) { } func TestMintPosition02LowerRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 0) foo.Approve(a2u(consts.POOL_ADDR), 50000000) @@ -80,7 +80,7 @@ func TestMintPosition02LowerRange(t *testing.T) { } func TestMintPosition03UpperRange(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 50000000) foo.Approve(a2u(consts.POOL_ADDR), 0) @@ -124,10 +124,10 @@ func TestUnclaimedFee0(t *testing.T) { } func TestSwap1(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 1234567) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( barPath, @@ -153,10 +153,10 @@ func TestUnclaimedFee1(t *testing.T) { } func TestSwap2(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( barPath, @@ -182,10 +182,10 @@ func TestUnclaimedFee2(t *testing.T) { } func TestSwap3(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.ROUTER_PATH) + std.TestSetRealm(rouRealm) std.TestSetOrigCaller(gsa) amount0, amount1 := pl.Swap( fooPath, @@ -211,7 +211,7 @@ func TestUnclaimedFee3(t *testing.T) { } func TestCollectFeeAfterSwap(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // COLLECT_FEE @@ -226,7 +226,7 @@ func TestCollectFeeAfterSwap(t *testing.T) { } func TestDecreaseLiquidityUpperPosition(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) ownerOfPosition := gnft.OwnerOf(tid(3)) shouldEQ(t, ownerOfPosition, std.GetOrigCaller()) diff --git a/router/_TEST_/_TEST_0_INIT_TOKEN_REGISTER_test.gno b/router/_TEST_/__TEST_0_INIT_TOKEN_REGISTER_test.gno similarity index 100% rename from router/_TEST_/_TEST_0_INIT_TOKEN_REGISTER_test.gno rename to router/_TEST_/__TEST_0_INIT_TOKEN_REGISTER_test.gno diff --git a/router/_TEST_/_TEST_0_INIT_VARS_HELPERS_test.gno b/router/_TEST_/__TEST_0_INIT_VARS_HELPERS_test.gno similarity index 87% rename from router/_TEST_/_TEST_0_INIT_VARS_HELPERS_test.gno rename to router/_TEST_/__TEST_0_INIT_VARS_HELPERS_test.gno index 86136abe..842de669 100644 --- a/router/_TEST_/_TEST_0_INIT_VARS_HELPERS_test.gno +++ b/router/_TEST_/__TEST_0_INIT_VARS_HELPERS_test.gno @@ -27,6 +27,14 @@ var ( max_timeout int64 = 9999999999 ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + /* HELPER */ func shouldEQ(t *testing.T, got, expected interface{}) { if got != expected { diff --git a/router/_TEST_/z1_swap_route_1route_1hop_filetest.gno b/router/_TEST_/__TEST_Z_z1_swap_route_1route_1hop_filetest.gnoA similarity index 94% rename from router/_TEST_/z1_swap_route_1route_1hop_filetest.gno rename to router/_TEST_/__TEST_Z_z1_swap_route_1route_1hop_filetest.gnoA index e4fd2d48..f4f83af1 100644 --- a/router/_TEST_/z1_swap_route_1route_1hop_filetest.gno +++ b/router/_TEST_/__TEST_Z_z1_swap_route_1route_1hop_filetest.gnoA @@ -44,6 +44,14 @@ var ( t *testing.T ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -170,7 +178,8 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -203,7 +212,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -214,11 +223,11 @@ func createPool() { } func mint() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) _, _, amount0, amount1 := pn.Mint(barPath, bazPath, fee500, int32(9000), int32(11000), "100000", "100000", "0", "0", maxTimeout, gsa.String()) if amount0 != "36790" { "router_z2_mint() || amount0 should be 36790" @@ -229,7 +238,7 @@ func mint() { } func drySwapBarBazExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( barPath, // inputToken @@ -245,7 +254,7 @@ func drySwapBarBazExactIn() { } func swapBarBazExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), uint64(1000)) baz.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // ITS FOR 0.15% fee @@ -268,7 +277,7 @@ func swapBarBazExactIn() { } func drySwapBarBazExactOut() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( barPath, // inputToken @@ -284,7 +293,7 @@ func drySwapBarBazExactOut() { } func swapBarBazExactOut() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), uint64(1000)) baz.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // ITS FOR 0.15% fee @@ -307,7 +316,7 @@ func swapBarBazExactOut() { } func drySwapBazBarExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( bazPath, // inputToken @@ -323,7 +332,7 @@ func drySwapBazBarExactIn() { } func swapBazBarExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) bar.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // ITS FOR 0.15% fee @@ -346,7 +355,7 @@ func swapBazBarExactIn() { } func drySwapBazBarExactOut() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( bazPath, // inputToken @@ -362,7 +371,7 @@ func drySwapBazBarExactOut() { } func swapBazBarExactOut() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) amountIn, amountOut := rr.SwapRoute( diff --git a/router/_TEST_/z2_swap_route_1route_1hop_out_range_filetest.gno b/router/_TEST_/__TEST_Z_z2_swap_route_1route_1hop_out_range_filetest.gnoA similarity index 94% rename from router/_TEST_/z2_swap_route_1route_1hop_out_range_filetest.gno rename to router/_TEST_/__TEST_Z_z2_swap_route_1route_1hop_out_range_filetest.gnoA index 4f21dfbe..cf37062f 100644 --- a/router/_TEST_/z2_swap_route_1route_1hop_out_range_filetest.gno +++ b/router/_TEST_/__TEST_Z_z2_swap_route_1route_1hop_out_range_filetest.gnoA @@ -44,6 +44,14 @@ var ( t *testing.T ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -170,7 +178,9 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -197,7 +207,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -208,11 +218,11 @@ func createPool() { } func mint() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) _, _, amount0, amount1 := pn.Mint(barPath, bazPath, fee500, int32(12000), int32(15000), "100000", "100000", "0", "0", maxTimeout, gsa.String()) // only bar, no baz if amount0 != "36790" { @@ -224,7 +234,7 @@ func mint() { } func drySwapBarBazExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( barPath, // inputToken @@ -240,7 +250,7 @@ func drySwapBarBazExactIn() { } func swapBarBazExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), uint64(1000)) baz.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // ITS FOR 0.15% fee diff --git a/router/_TEST_/z3_swap_route_1route_1hop_native_in_out_filetest.gno b/router/_TEST_/__TEST_Z_z3_swap_route_1route_1hop_native_in_out_filetest.gnoA similarity index 93% rename from router/_TEST_/z3_swap_route_1route_1hop_native_in_out_filetest.gno rename to router/_TEST_/__TEST_Z_z3_swap_route_1route_1hop_native_in_out_filetest.gnoA index 46eb4fd7..aa66d300 100644 --- a/router/_TEST_/z3_swap_route_1route_1hop_native_in_out_filetest.gno +++ b/router/_TEST_/__TEST_Z_z3_swap_route_1route_1hop_native_in_out_filetest.gnoA @@ -44,6 +44,14 @@ var ( t *testing.T ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -170,7 +178,9 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -201,7 +211,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*3) std.TestSkipHeights(1) @@ -214,11 +224,11 @@ func createPool() { } func mintBarBaz() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) _, _, amount0, amount1 := pn.Mint(barPath, bazPath, fee500, int32(9000), int32(11000), "100000", "100000", "0", "0", maxTimeout, gsa.String()) if amount0 != "36790" { "router_z4_mintBarBaz() || amount0 should be 36790" @@ -229,11 +239,11 @@ func mintBarBaz() { } func mintBazQux() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) _, _, amount0, amount1 := pn.Mint(bazPath, quxPath, fee500, int32(9000), int32(11000), "100000", "100000", "0", "0", maxTimeout, gsa.String()) if amount0 != "36790" { "router_z4_mintBazQux() || amount0 should be 36790" @@ -244,22 +254,21 @@ func mintBazQux() { } func mintQuxGnot() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // send std.TestIssueCoins(gsa, std.Coins{{"ugnot", 1000009}}) std.TestSetOrigSend(std.Coins{{"ugnot", 1000009}}, nil) testBanker := std.GetBanker(std.BankerTypeRealmIssue) - testBanker.RemoveCoin(std.GetOrigCaller(), "ugnot", 1000009) // Deposit(wrap) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) wugnot.Deposit() qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) wugnot.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) _, _, amount0, amount1 := pn.Mint(quxPath, consts.WRAPPED_WUGNOT, fee500, int32(9000), int32(11000), "100000", "100000", "0", "0", maxTimeout, gsa.String()) if amount0 != "36790" { "router_z4_mintQuxGnot() || amount0 should be 36790" @@ -270,7 +279,7 @@ func mintQuxGnot() { } func drySwapBarGnotExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( barPath, // inputToken @@ -286,7 +295,7 @@ func drySwapBarGnotExactIn() { } func drySwapBarGnotExactOut() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( barPath, // inputToken @@ -302,7 +311,7 @@ func drySwapBarGnotExactOut() { } func drySwapGnotBarExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( consts.WRAPPED_WUGNOT, // intputToken @@ -318,7 +327,7 @@ func drySwapGnotBarExactIn() { } func drySwapGnotBarExactOut() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( consts.WRAPPED_WUGNOT, // intputToken diff --git a/router/_TEST_/z4_swap_route_1route_2hop_wrapped_middle_filetest.gno b/router/_TEST_/__TEST_Z_z4_swap_route_1route_2hop_wrapped_middle_filetest.gnoA similarity index 92% rename from router/_TEST_/z4_swap_route_1route_2hop_wrapped_middle_filetest.gno rename to router/_TEST_/__TEST_Z_z4_swap_route_1route_2hop_wrapped_middle_filetest.gnoA index 32cf229a..2967b7c9 100644 --- a/router/_TEST_/z4_swap_route_1route_2hop_wrapped_middle_filetest.gno +++ b/router/_TEST_/__TEST_Z_z4_swap_route_1route_2hop_wrapped_middle_filetest.gnoA @@ -44,6 +44,14 @@ var ( t *testing.T ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -170,7 +178,9 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -198,7 +208,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*2) std.TestSkipHeights(1) @@ -210,22 +220,21 @@ func createPool() { } func mintGnsGnot() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // send std.TestIssueCoins(gsa, std.Coins{{"ugnot", 999999}}) std.TestSetOrigSend(std.Coins{{"ugnot", 999999}}, nil) testBanker := std.GetBanker(std.BankerTypeRealmIssue) - testBanker.RemoveCoin(std.GetOrigCaller(), "ugnot", 999999) // Deposit(wrap) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) wugnot.Deposit() gns.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) wugnot.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) _, _, amount0, amount1 := pn.Mint(consts.GNS_PATH, consts.WRAPPED_WUGNOT, fee100, int32(9000), int32(11000), "100000", "100000", "0", "0", maxTimeout, gsa.String()) if amount0 != "36790" { "router_z5_mintGnsGnot() || amount0 should be 36790" @@ -236,27 +245,26 @@ func mintGnsGnot() { } func mintGnotBar() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // send std.TestIssueCoins(gsa, std.Coins{{"ugnot", 999999}}) std.TestSetOrigSend(std.Coins{{"ugnot", 999999}}, nil) testBanker := std.GetBanker(std.BankerTypeRealmIssue) - testBanker.RemoveCoin(std.GetOrigCaller(), "ugnot", 999999) // Deposit(wrap) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) wugnot.Deposit() wugnot.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) tokenId, liquidity, amount0, amount1 := pn.Mint(consts.WRAPPED_WUGNOT, barPath, fee100, int32(9000), int32(11000), "100000", "100000", "0", "0", maxTimeout, gsa.String()) } func drySwapGnsBarExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( consts.GNS_PATH, // inputToken @@ -266,13 +274,13 @@ func drySwapGnsBarExactIn() { "gno.land/r/demo/gns:gno.land/r/demo/wugnot:100*POOL*gno.land/r/demo/wugnot:gno.land/r/demo/bar:100", // strRouteArr "100", // quoteArr ) - if dryResult != "7339" { - panic("dryResult should be 7339") + if dryResult != "7325" { + panic("dryResult should be 7325") } } func swapGnsBarExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), 1000) // swap input amount bar.Approve(a2u(consts.ROUTER_ADDR), 7328) // 0.15% fee @@ -289,7 +297,7 @@ func swapGnsBarExactIn() { if amountIn != "1000" { panic("amountIn should be 1000") } - if amountOut != "-7328" { - panic("amountOut should be -7328") + if amountOut != "-7315" { + panic("amountOut should be -7315") } } diff --git a/router/_TEST_/z5_dry_and_swap_filetest.gno b/router/_TEST_/__TEST_Z_z5_dry_and_swap_filetest.gnoA similarity index 91% rename from router/_TEST_/z5_dry_and_swap_filetest.gno rename to router/_TEST_/__TEST_Z_z5_dry_and_swap_filetest.gnoA index 1adf4265..04bf82c3 100644 --- a/router/_TEST_/z5_dry_and_swap_filetest.gno +++ b/router/_TEST_/__TEST_Z_z5_dry_and_swap_filetest.gnoA @@ -44,6 +44,14 @@ var ( t *testing.T ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -170,7 +178,9 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -213,7 +223,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875 @@ -235,11 +245,11 @@ func createPool() { } func mintBarBaz() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) _, _, amount0, amount1 := pn.Mint(barPath, bazPath, fee100, int32(9000), int32(11000), "100000000", "100000000", "0", "0", maxTimeout, gsa.String()) if amount0 != "36789784" { panic("router_z6_mintBarBaz() || amount0 should be 36789784") @@ -250,11 +260,11 @@ func mintBarBaz() { } func mintBazFoo() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) _, _, amount0, amount1 := pn.Mint(bazPath, fooPath, fee100, int32(9000), int32(11000), "100000000", "100000000", "0", "0", maxTimeout, gsa.String()) if amount0 != "36789784" { panic("router_z6_mintBazFoo() || amount0 should be 36789784") @@ -265,11 +275,11 @@ func mintBazFoo() { } func mintFooQux() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) _, _, amount0, amount1 := pn.Mint(fooPath, quxPath, fee100, int32(9000), int32(11000), "100000000", "100000000", "0", "0", maxTimeout, gsa.String()) if amount0 != "36789784" { panic("router_z6_mintBazFoo() || amount0 should be 36789784") @@ -281,7 +291,7 @@ func mintFooQux() { // BAR > BAZ > ExactIn || DRY func drySwapBarBazExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( barPath, // inputToken @@ -291,14 +301,14 @@ func drySwapBarBazExactIn() { "gno.land/r/demo/bar:gno.land/r/demo/baz:100", // strRouteArr "100", // quoteArr ) - if dryResult != "2714276" { - panic("router_z6_drySwapBarBazExactIn() || dryResult should be 2714276") + if dryResult != "2714272" { + panic("router_z6_drySwapBarBazExactIn() || dryResult should be 2714272") } } // BAR > BAZ > ExactIn || SWAP func swapBarBazExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // swap input amount baz.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // 0.15% fee @@ -315,14 +325,14 @@ func swapBarBazExactIn() { if amountIn != "1000000" { panic("router_z6_swapBarBazExactIn() || amountIn should be 1000000") } - if amountOut != "-2710205" { - panic("router_z6_swapBarBazExactIn() || amountIn should be -2710205") + if amountOut != "-2710201" { + panic("router_z6_swapBarBazExactIn() || amountIn should be -2710201") } } // BAZ > BAR > ExactIn || DRY func drySwapBazBarExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( bazPath, // inputToken @@ -332,14 +342,14 @@ func drySwapBazBarExactIn() { "gno.land/r/demo/baz:gno.land/r/demo/bar:100", // strRouteArr "100", // quoteArr ) - if dryResult != "999799" { - panic("router_z6_drySwapBazBarExactIn() || dryResult should be 999799") + if dryResult != "999798" { + panic("router_z6_drySwapBazBarExactIn() || dryResult should be 999798") } } // BAZ > BAR > ExactIn || SWAP func swapBazBarExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // swap input amount bar.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // 0.15% fee @@ -356,14 +366,14 @@ func swapBazBarExactIn() { if amountIn != "2714276" { panic("router_z6_swapBazBarExactIn() || amountIn should be 2714276") } - if amountOut != "-998300" { - panic("router_z6_swapBazBarExactIn() || amountIn should be -998300") + if amountOut != "-998299" { + panic("router_z6_swapBazBarExactIn() || amountIn should be -998299") } } // BAR > BAZ > ExactOut || DRY func drySwapBarBazExactOut() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( barPath, // inputToken @@ -373,14 +383,14 @@ func drySwapBarBazExactOut() { "gno.land/r/demo/bar:gno.land/r/demo/baz:100", // strRouteArr "100", // quoteArr ) - if dryResult != "1000002" { - panic("router_z6_drySwapBarBazExactOut() || dryResult should be 1000002") // + if dryResult != "1000003" { + panic("router_z6_drySwapBarBazExactOut() || dryResult should be 1000003") // } } // BAR > BAZ > ExactOut || SWAP func swapBarBazExactOut() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // swap input amount baz.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // 0.15% fee @@ -392,10 +402,10 @@ func swapBarBazExactOut() { "EXACT_OUT", // swapType "gno.land/r/demo/bar:gno.land/r/demo/baz:100", // strRouteArr "100", // quoteArr - "1000002", // tokenAmountLimit + "1000003", // tokenAmountLimit ) - if amountIn != "1000002" { - panic("router_z6_swapBarBazExactOut() || amountIn should be 1000002") + if amountIn != "1000003" { + panic("router_z6_swapBarBazExactOut() || amountIn should be 1000003") } if amountOut != "-2710205" { panic("router_z6_swapBarBazExactOut() || amountIn should be 1000002") @@ -404,7 +414,7 @@ func swapBarBazExactOut() { // BAR > QUX > ExactIn || DRY func drySwapBarQuxExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( barPath, // inputToken @@ -414,14 +424,14 @@ func drySwapBarQuxExactIn() { "gno.land/r/demo/bar:gno.land/r/demo/baz:100*POOL*gno.land/r/demo/baz:gno.land/r/demo/foo:100*POOL*gno.land/r/demo/foo:gno.land/r/demo/qux:100", // strRouteArr "100", // quoteArr ) - if dryResult != "19733647" { - panic("router_z6_drySwapBarQuxExactIn() || amountIn should be 19733647") + if dryResult != "19733638" { + panic("router_z6_drySwapBarQuxExactIn() || amountIn should be 19733638") } } // BAR > QUX > ExactIn || SWAP func swapBarQuxExactIn() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // swap input amount qux.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // 0.15% fee @@ -439,14 +449,14 @@ func swapBarQuxExactIn() { if amountIn != "1000000" { panic("router_z6_swapBarQuxExactIn() || amountIn should be 1000000") } - if amountOut != "-19704047" { - panic("router_z6_swapBarQuxExactIn() || amountIn should be -19704047") + if amountOut != "-19704038" { + panic("router_z6_swapBarQuxExactIn() || amountIn should be -19704038") } } // QUX > BAR > ExactOut || DRY func drySwapQuxBarExactOut() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := rr.DrySwapRoute( quxPath, // inputToken @@ -456,14 +466,14 @@ func drySwapQuxBarExactOut() { "gno.land/r/demo/qux:gno.land/r/demo/foo:100*POOL*gno.land/r/demo/foo:gno.land/r/demo/baz:100*POOL*gno.land/r/demo/baz:gno.land/r/demo/bar:100", // strRouteArr "100", // quoteArr ) - if dryResult != "40079942" { - panic("router_z6_drySwapQuxBarExactOut() || amountIn should be 40079942") + if dryResult != "40079976" { + panic("router_z6_drySwapQuxBarExactOut() || amountIn should be 40079976") } } // QUX > BAR > ExactOut || SWAP func swapQuxBarExactOut() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // swap input amount bar.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // 0.15% fee @@ -475,11 +485,11 @@ func swapQuxBarExactOut() { "EXACT_OUT", // swapType "gno.land/r/demo/qux:gno.land/r/demo/foo:100*POOL*gno.land/r/demo/foo:gno.land/r/demo/baz:100*POOL*gno.land/r/demo/baz:gno.land/r/demo/bar:100", // strRouteArr "100", // quoteArr - "40079942", // tokenAmountLimit + "40079976", // tokenAmountLimit ) - if amountIn != "40079942" { - panic("router_z6_swapQuxBarExactOut() || amountIn should be 40079942") + if amountIn != "40079976" { + panic("router_z6_swapQuxBarExactOut() || amountIn should be 40079976") } if amountOut != "-1997000" { panic("router_z6_swapQuxBarExactOut() || amountIn should be -1997000") diff --git a/router/_TEST_/_TEST_router_all_2_route_2_hop_test.gnoA b/router/_TEST_/__TEST_router_all_2_route_2_hop_test.gnoA similarity index 98% rename from router/_TEST_/_TEST_router_all_2_route_2_hop_test.gnoA rename to router/_TEST_/__TEST_router_all_2_route_2_hop_test.gnoA index ca55fac5..6d4e8c1c 100644 --- a/router/_TEST_/_TEST_router_all_2_route_2_hop_test.gnoA +++ b/router/_TEST_/__TEST_router_all_2_route_2_hop_test.gnoA @@ -16,7 +16,7 @@ import ( ) func TestCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*2) @@ -28,7 +28,7 @@ func TestCreatePool(t *testing.T) { func TestPositionMint(t *testing.T) { // bar_baz_500 by gsa - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -57,7 +57,7 @@ func TestDrySwapRouteBarQuxExactIn(t *testing.T) { } func TestSwapRouteBarQuxExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 10000) qux.Approve(a2u(consts.ROUTER_ADDR), 10000) @@ -77,7 +77,7 @@ func TestSwapRouteBarQuxExactIn(t *testing.T) { } func TestDrySwapRouteBarQuxExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := DrySwapRoute( barPath, // inputToken @@ -97,7 +97,7 @@ func TestDrySwapRouteBarQuxExactOut(t *testing.T) { } func TestSwapRouteBarQuxExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) amountIn, amountOut := SwapRoute( barPath, // inputToken @@ -119,7 +119,7 @@ func TestSwapRouteBarQuxExactOut(t *testing.T) { } func TestDrySwapRouteQuxBarExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := DrySwapRoute( quxPath, // inputToken @@ -134,7 +134,7 @@ func TestDrySwapRouteQuxBarExactIn(t *testing.T) { } func TestSwapRouteQuxBarExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) amountIn, amountOut := SwapRoute( quxPath, // inputToken @@ -156,7 +156,7 @@ func TestSwapRouteQuxBarExactIn(t *testing.T) { } func TestDrySwapRouteQuxBarExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := DrySwapRoute( quxPath, // inputToken @@ -171,7 +171,7 @@ func TestDrySwapRouteQuxBarExactOut(t *testing.T) { } func TestSwapRouteQuxBarExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) qux.Approve(a2u(consts.POOL_ADDR), 10000) bar.Approve(a2u(consts.ROUTER_ADDR), 10000) diff --git a/router/_TEST_/_TEST_router_swap_route_1route_1hop_native_in_out_test.gnoA b/router/_TEST_/__TEST_router_swap_route_1route_1hop_native_in_out_test.gnoA similarity index 98% rename from router/_TEST_/_TEST_router_swap_route_1route_1hop_native_in_out_test.gnoA rename to router/_TEST_/__TEST_router_swap_route_1route_1hop_native_in_out_test.gnoA index d880e426..6cd45e95 100644 --- a/router/_TEST_/_TEST_router_swap_route_1route_1hop_native_in_out_test.gnoA +++ b/router/_TEST_/__TEST_router_swap_route_1route_1hop_native_in_out_test.gnoA @@ -19,7 +19,7 @@ import ( ) func TestCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*3) @@ -49,7 +49,7 @@ func TestCreatePool(t *testing.T) { } func TestPositionMintBarBaz(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) tokenId, liquidity, amount0, amount1 := pn.Mint(barPath, bazPath, fee500, int32(9000), int32(11000), "100000", "100000", "0", "0", max_timeout, gsa.String()) @@ -61,7 +61,7 @@ func TestPositionMintBarBaz(t *testing.T) { } func TestPositionMintBazQux(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -75,7 +75,7 @@ func TestPositionMintBazQux(t *testing.T) { } func TestPositionMintQuxGnot(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // send std.TestIssueCoins(consts.POSITION_ADDR, std.Coins{{"ugnot", 1000009}}) @@ -110,7 +110,7 @@ func TestDrySwapRouteBarGnotExactIn(t *testing.T) { // BUY NATIVE func TestSwapRouteBarGnotExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) wugnot.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // for output diff --git a/router/_TEST_/_TEST_router_swap_route_1route_1hop_out_range_test.gnoA b/router/_TEST_/__TEST_router_swap_route_1route_1hop_out_range_test.gnoA similarity index 98% rename from router/_TEST_/_TEST_router_swap_route_1route_1hop_out_range_test.gnoA rename to router/_TEST_/__TEST_router_swap_route_1route_1hop_out_range_test.gnoA index ed92f1f0..00f9552b 100644 --- a/router/_TEST_/_TEST_router_swap_route_1route_1hop_out_range_test.gnoA +++ b/router/_TEST_/__TEST_router_swap_route_1route_1hop_out_range_test.gnoA @@ -17,7 +17,7 @@ import ( ) func TestCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(barPath, bazPath, fee500, "130621891405341611593710811006") // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875 @@ -39,7 +39,7 @@ func TestCreatePool(t *testing.T) { func TestPositionMint(t *testing.T) { // bar_baz_500 by gsa - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) diff --git a/router/_TEST_/_TEST_router_swap_route_1route_1hop_test.gnoA b/router/_TEST_/__TEST_router_swap_route_1route_1hop_test.gnoA similarity index 96% rename from router/_TEST_/_TEST_router_swap_route_1route_1hop_test.gnoA rename to router/_TEST_/__TEST_router_swap_route_1route_1hop_test.gnoA index 895737dd..8f01b223 100644 --- a/router/_TEST_/_TEST_router_swap_route_1route_1hop_test.gnoA +++ b/router/_TEST_/__TEST_router_swap_route_1route_1hop_test.gnoA @@ -16,7 +16,7 @@ import ( ) func TestCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(barPath, bazPath, fee500, "130621891405341611593710811006") // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875 @@ -29,7 +29,7 @@ func TestCreatePool(t *testing.T) { func TestPositionMint(t *testing.T) { // bar_baz_500 by gsa - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 36790) baz.Approve(a2u(consts.POOL_ADDR), 100000) @@ -43,7 +43,7 @@ func TestPositionMint(t *testing.T) { } func TestDrySwapRouteBarBazExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := DrySwapRoute( barPath, // inputToken @@ -58,7 +58,7 @@ func TestDrySwapRouteBarBazExactIn(t *testing.T) { } func TestSwapRouteBarBazExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), uint64(1000)) baz.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // ITS FOR 0.15% fee @@ -80,7 +80,7 @@ func TestSwapRouteBarBazExactIn(t *testing.T) { } func TestDrySwapRouteBarBazExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := DrySwapRoute( barPath, // inputToken @@ -95,7 +95,7 @@ func TestDrySwapRouteBarBazExactOut(t *testing.T) { } func TestSwapRouteBarBazExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), uint64(1000)) baz.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // ITS FOR 0.15% fee @@ -117,7 +117,7 @@ func TestSwapRouteBarBazExactOut(t *testing.T) { } func TestDrySwapRouteBazBarExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := DrySwapRoute( bazPath, // inputToken @@ -132,7 +132,7 @@ func TestDrySwapRouteBazBarExactIn(t *testing.T) { } func TestSwapRouteBazBarExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) bar.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // ITS FOR 0.15% fee @@ -154,7 +154,7 @@ func TestSwapRouteBazBarExactIn(t *testing.T) { } func TestDrySwapRouteBazBarExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := DrySwapRoute( bazPath, // inputToken @@ -169,7 +169,7 @@ func TestDrySwapRouteBazBarExactOut(t *testing.T) { } func TestSwapRouteBazBarExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) amountIn, amountOut := SwapRoute( diff --git a/router/_TEST_/_TEST_router_swap_route_1route_2hop_wrapped_native_in_out_test.gnoA b/router/_TEST_/__TEST_router_swap_route_1route_2hop_wrapped_native_in_out_test.gnoA similarity index 97% rename from router/_TEST_/_TEST_router_swap_route_1route_2hop_wrapped_native_in_out_test.gnoA rename to router/_TEST_/__TEST_router_swap_route_1route_2hop_wrapped_native_in_out_test.gnoA index e883f138..ee98120d 100644 --- a/router/_TEST_/_TEST_router_swap_route_1route_2hop_wrapped_native_in_out_test.gnoA +++ b/router/_TEST_/__TEST_router_swap_route_1route_2hop_wrapped_native_in_out_test.gnoA @@ -17,7 +17,7 @@ import ( ) func TestCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*3) @@ -38,7 +38,7 @@ func TestCreatePool(t *testing.T) { } func TestPositionMintBarBaz(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) tokenId, liquidity, amount0, amount1 := pn.Mint(barPath, bazPath, fee500, int32(9000), int32(11000), "100000", "100000", "0", "0", max_timeout, gsa.String()) @@ -50,7 +50,7 @@ func TestPositionMintBarBaz(t *testing.T) { } func TestPositionMintBazQux(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -64,14 +64,14 @@ func TestPositionMintBazQux(t *testing.T) { } func TestPositionMintQuxGnot(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // send std.TestIssueCoins(gsa, std.Coins{{"ugnot", 1000009}}) std.TestSetOrigSend(std.Coins{{"ugnot", 1000009}}, nil) // Deposit(wrap) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) wugnot.Deposit() qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) diff --git a/router/_TEST_/_TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gnoA b/router/_TEST_/__TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gnoA similarity index 96% rename from router/_TEST_/_TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gnoA rename to router/_TEST_/__TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gnoA index 0e101e8c..5569485b 100644 --- a/router/_TEST_/_TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gnoA +++ b/router/_TEST_/__TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gnoA @@ -15,7 +15,7 @@ import ( ) func TestCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*2) @@ -33,14 +33,14 @@ func TestCreatePool(t *testing.T) { } func TestPositionMintGnsGnot(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // send std.TestIssueCoins(gsa, std.Coins{{"ugnot", 100000}}) std.TestSetOrigSend(std.Coins{{"ugnot", 100000}}, nil) // Deposit(wrap) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) wugnot.Deposit() gns.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -63,7 +63,7 @@ func TestPositionMintGnotBar(t *testing.T) { testBanker := std.GetBanker(std.BankerTypeRealmIssue) // Deposit(wrap) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) wugnot.Deposit() wugnot.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -88,11 +88,11 @@ func TestDrySwapRouteGnsBarExactIn(t *testing.T) { "gno.land/r/demo/gns:gno.land/r/demo/wugnot:100*POOL*gno.land/r/demo/wugnot:gno.land/r/demo/bar:100", // strRouteArr "100", // quoteArr ) - shouldEQ(t, dryResult, "7339") + shouldEQ(t, dryResult, "7325") } func TestSwapRouteGnsBarExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), 1000) // swap input amount bar.Approve(a2u(consts.ROUTER_ADDR), 7328) // 0.15% fee @@ -111,5 +111,5 @@ func TestSwapRouteGnsBarExactIn(t *testing.T) { // --- event: {GNOSWAP gno.land/r/demo/router SwapRoute [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_input gno.land/r/demo/gns} {p_output gno.land/r/demo/bar} {p_swapType EXACT_IN} {p_amountSpecified 1000} {p_route gno.land/r/demo/gns:gno.land/r/demo/wugnot:100*POOL*gno.land/r/demo/wugnot:gno.land/r/demo/bar:100} {p_quote 100} {amountIn 1000} {amountOut -7328}]} shouldEQ(t, amountIn, "1000") - shouldEQ(t, amountOut, "-7328") + shouldEQ(t, amountOut, "-7315") } diff --git a/router/_TEST_/_TEST_router_swap_route_2route_2hop_test.gnoA b/router/_TEST_/__TEST_router_swap_route_2route_2hop_test.gnoA similarity index 98% rename from router/_TEST_/_TEST_router_swap_route_2route_2hop_test.gnoA rename to router/_TEST_/__TEST_router_swap_route_2route_2hop_test.gnoA index 4b4d5994..3c4ba0db 100644 --- a/router/_TEST_/_TEST_router_swap_route_2route_2hop_test.gnoA +++ b/router/_TEST_/__TEST_router_swap_route_2route_2hop_test.gnoA @@ -16,7 +16,7 @@ import ( ) func TestCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*2) pl.CreatePool(barPath, bazPath, uint16(500), "130621891405341611593710811006") // tick = 10_000, ratio = 2.71814592682522526700950038502924144268035888671875 @@ -32,7 +32,7 @@ func TestCreatePool(t *testing.T) { func TestPositionMint(t *testing.T) { // bar_baz_500 by gsa - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -62,7 +62,7 @@ func TestDrySwapRouteBarQuxExactIn(t *testing.T) { } func TestSwapRouteBarQuxExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), 10000) qux.Approve(a2u(consts.ROUTER_ADDR), 10000) @@ -87,7 +87,7 @@ func TestSwapRouteBarQuxExactIn(t *testing.T) { } func TestDrySwapRouteBarQuxExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := DrySwapRoute( barPath, // inputToken @@ -102,7 +102,7 @@ func TestDrySwapRouteBarQuxExactOut(t *testing.T) { } func TestSwapRouteBarQuxExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) amountIn, amountOut := SwapRoute( barPath, // inputToken @@ -124,7 +124,7 @@ func TestSwapRouteBarQuxExactOut(t *testing.T) { } func TestDrySwapRouteQuxBarExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := DrySwapRoute( quxPath, // inputToken @@ -139,7 +139,7 @@ func TestDrySwapRouteQuxBarExactIn(t *testing.T) { } func TestSwapRouteQuxBarExactIn(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) amountIn, amountOut := SwapRoute( quxPath, // inputToken @@ -156,7 +156,7 @@ func TestSwapRouteQuxBarExactIn(t *testing.T) { } func TestDrySwapRouteQuxBarExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) dryResult := DrySwapRoute( quxPath, // inputToken @@ -176,7 +176,7 @@ func TestDrySwapRouteQuxBarExactOut(t *testing.T) { } func TestwapRouteQuxBarExactOut(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) qux.Approve(a2u(consts.POOL_ADDR), 10000) bar.Approve(a2u(consts.ROUTER_ADDR), 10000) diff --git a/staker/_TEST_/__TEST_0_INIT_VARIABLE_AND_HELPER_test.gno b/staker/_TEST_/__TEST_0_INIT_VARIABLE_AND_HELPER_test.gno index 0aa89d5e..4c13cffa 100644 --- a/staker/_TEST_/__TEST_0_INIT_VARIABLE_AND_HELPER_test.gno +++ b/staker/_TEST_/__TEST_0_INIT_VARIABLE_AND_HELPER_test.gno @@ -9,6 +9,7 @@ import ( var ( gsa std.Address = consts.GNOSWAP_ADMIN + ira std.Address = consts.INTERNAL_REWARD_ACCOUNT fooPath string = "gno.land/r/demo/foo" barPath string = "gno.land/r/demo/bar" @@ -26,6 +27,16 @@ var ( max_timeout int64 = 9999999999 ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + iraRealm = std.NewUserRealm(ira) + + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + /* HELPER */ func ugnotBalanceOf(addr std.Address) uint64 { testBanker := std.GetBanker(std.BankerTypeRealmIssue) diff --git a/staker/_TEST_/__TEST_Z_z1_one_increase_external_filetest.gnoA b/staker/_TEST_/__TEST_Z_z1_one_increase_external_filetest.gnoA index ccc4422c..60fd41b8 100644 --- a/staker/_TEST_/__TEST_Z_z1_one_increase_external_filetest.gnoA +++ b/staker/_TEST_/__TEST_Z_z1_one_increase_external_filetest.gnoA @@ -29,6 +29,7 @@ import ( var ( gsa std.Address = consts.GNOSWAP_ADMIN + ira std.Address = consts.INTERNAL_REWARD_ACCOUNT fooPath string = "gno.land/r/demo/foo" barPath string = "gno.land/r/demo/bar" @@ -51,6 +52,16 @@ var ( t *testing.T ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + iraRealm = std.NewUserRealm(ira) + + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -192,7 +203,9 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -231,7 +244,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*0) std.TestSkipHeights(1) @@ -245,7 +258,7 @@ func mint01() { bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) pn.Mint(barPath, fooPath, fee100, 9000, 11000, "1000", "1000", "0", "0", max_timeout, gsa.String()) } @@ -255,12 +268,12 @@ func mint02() { bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) pn.Mint(barPath, fooPath, fee100, 9100, 12000, "5000", "5000", "0", "0", max_timeout, gsa.String()) } func createExternalIncentiveInit() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.STAKER_ADDR), 10_000_000_000) std.TestSkipHeights(1) @@ -275,7 +288,7 @@ func createExternalIncentiveInit() { } func createExternalIncentiveIncrease() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.STAKER_ADDR), 10_000_000_000) std.TestSkipHeights(1) @@ -290,14 +303,14 @@ func createExternalIncentiveIncrease() { } func stakeToken01() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(consts.STAKER_ADDR), tid(1)) sr.StakeToken(1) std.TestSkipHeights(2) } func stakeToken02() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(consts.STAKER_ADDR), tid(2)) sr.StakeToken(2) std.TestSkipHeights(2) diff --git a/staker/_TEST_/__TEST_Z_z2_one_external_filetest.gnoA b/staker/_TEST_/__TEST_Z_z2_one_external_filetest.gnoA index 0af6e0c3..1726231b 100644 --- a/staker/_TEST_/__TEST_Z_z2_one_external_filetest.gnoA +++ b/staker/_TEST_/__TEST_Z_z2_one_external_filetest.gnoA @@ -29,6 +29,7 @@ import ( var ( gsa std.Address = consts.GNOSWAP_ADMIN + ira std.Address = consts.INTERNAL_REWARD_ACCOUNT fooPath string = "gno.land/r/demo/foo" barPath string = "gno.land/r/demo/bar" @@ -51,6 +52,16 @@ var ( t *testing.T ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + iraRealm = std.NewUserRealm(ira) + + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -192,7 +203,9 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -232,7 +245,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*0) std.TestSkipHeights(1) @@ -246,7 +259,7 @@ func mint01() { bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) pn.Mint(barPath, fooPath, fee100, 9000, 11000, "1000", "1000", "0", "0", max_timeout, gsa.String()) } @@ -256,12 +269,12 @@ func mint02() { bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) pn.Mint(barPath, fooPath, fee100, 9100, 12000, "5000", "5000", "0", "0", max_timeout, gsa.String()) } func createExternalIncentive() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.STAKER_ADDR), 10_000_000_000) std.TestSkipHeights(1) @@ -276,25 +289,25 @@ func createExternalIncentive() { } func stakeToken01() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(consts.STAKER_ADDR), tid(1)) sr.StakeToken(1) std.TestSkipHeights(2) } func stakeToken02() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(consts.STAKER_ADDR), tid(2)) sr.StakeToken(2) std.TestSkipHeights(2) } func unStakeToken01() { - std.TestSetPrevAddr(consts.INTERNAL_REWARD_ACCOUNT) + std.TestSetRealm(iraRealm) gns.Approve(a2u(consts.STAKER_ADDR), consts.UINT64_MAX) // internal reward distribution std.TestSkipHeights(360) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) sr.UnstakeToken(1) // GNFT tokenId std.TestSkipHeights(1) @@ -306,7 +319,7 @@ func unStakeToken01() { } func unStakeToken02() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) sr.UnstakeToken(2) // GNFT tokenId std.TestSkipHeights(1) diff --git a/staker/_TEST_/__TEST_Z_z3_internal_external_filetest.gnoA b/staker/_TEST_/__TEST_Z_z3_internal_external_filetest.gnoA index 3f41afea..67f3ef8b 100644 --- a/staker/_TEST_/__TEST_Z_z3_internal_external_filetest.gnoA +++ b/staker/_TEST_/__TEST_Z_z3_internal_external_filetest.gnoA @@ -29,6 +29,7 @@ import ( var ( gsa std.Address = consts.GNOSWAP_ADMIN + ira std.Address = consts.INTERNAL_REWARD_ACCOUNT fooPath string = "gno.land/r/demo/foo" barPath string = "gno.land/r/demo/bar" @@ -51,6 +52,16 @@ var ( t *testing.T ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + iraRealm = std.NewUserRealm(ira) + + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -192,7 +203,9 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -235,7 +248,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*0) std.TestSkipHeights(1) @@ -247,7 +260,8 @@ func createPool() { } func setPoolTier() { - std.TestSetPrevAddr(consts.GNOSWAP_ADMIN) + std.TestSetRealm(gsaRealm) + sr.SetPoolTier("gno.land/r/demo/bar:gno.land/r/demo/qux:500", 1) sr.SetPoolTier("gno.land/r/demo/bar:gno.land/r/demo/baz:100", 1) @@ -255,40 +269,40 @@ func setPoolTier() { } func mintBarQux() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) pn.Mint(barPath, quxPath, fee500, 9000, 11000, "100000", "100000", "0", "0", maxTimeout, gsa.String()) } func mintBarBaz() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) pn.Mint(barPath, bazPath, fee100, -1000, 1000, "100000", "100000", "0", "0", maxTimeout, gsa.String()) } func mintFooQux() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) pn.Mint(fooPath, quxPath, fee500, -1000, 11000, "100000", "100000", "0", "0", maxTimeout, gsa.String()) } func createExternalIncentive() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.STAKER_ADDR), 10_000_000_000) std.TestSkipHeights(1) @@ -304,7 +318,7 @@ func createExternalIncentive() { } func stakeTier01() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(consts.STAKER_ADDR), tid(1)) sr.StakeToken(1) @@ -313,7 +327,7 @@ func stakeTier01() { } func stakeTier02() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(consts.STAKER_ADDR), tid(2)) sr.StakeToken(2) @@ -322,7 +336,7 @@ func stakeTier02() { } func stakeExternal() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(consts.STAKER_ADDR), tid(3)) sr.StakeToken(3) @@ -331,7 +345,7 @@ func stakeExternal() { } func collectReward01() { - std.TestSetPrevAddr(consts.INTERNAL_REWARD_ACCOUNT) + std.TestSetRealm(iraRealm) gns.Approve(a2u(consts.STAKER_ADDR), consts.UINT64_MAX) // internal reward distribution std.TestSkipHeights(1) @@ -341,7 +355,7 @@ func collectReward01() { panic("collectReward01() || gnsBal != 500000000000000") } - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) sr.CollectReward(1) @@ -353,7 +367,7 @@ func collectReward01() { } func collectReward01Again() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnsBal := gns.BalanceOf(a2u(gsa)) @@ -375,7 +389,7 @@ func collectReward01Again() { } func collectExternalReward() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) oblBal := obl.BalanceOf(a2u(gsa)) diff --git a/staker/_TEST_/__TEST_Z_z4_mint_and_stake_filetest.gnoA b/staker/_TEST_/__TEST_Z_z4_mint_and_stake_filetest.gnoA index c1dca5ce..e0a1e787 100644 --- a/staker/_TEST_/__TEST_Z_z4_mint_and_stake_filetest.gnoA +++ b/staker/_TEST_/__TEST_Z_z4_mint_and_stake_filetest.gnoA @@ -27,6 +27,7 @@ import ( var ( gsa std.Address = consts.GNOSWAP_ADMIN + ira std.Address = consts.INTERNAL_REWARD_ACCOUNT fooPath string = "gno.land/r/demo/foo" barPath string = "gno.land/r/demo/bar" @@ -49,6 +50,16 @@ var ( t *testing.T ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + iraRealm = std.NewUserRealm(ira) + + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -190,7 +201,9 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -226,7 +239,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*0) std.TestSkipHeights(1) @@ -236,7 +249,7 @@ func createPool() { } func mintAndStake() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) @@ -245,23 +258,18 @@ func mintAndStake() { } func collectFee() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) pn.CollectFee(1) } func collectReward() { // internal reward distribution - std.TestSetPrevAddr(consts.INTERNAL_REWARD_ACCOUNT) + std.TestSetRealm(iraRealm) gns.Approve(a2u(consts.STAKER_ADDR), consts.UINT64_MAX) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) sr.CollectReward(1) } -func unstakeToken() { - std.TestSetPrevAddr(gsa) - sr.UnstakeToken(1) -} - // Output: // diff --git a/staker/_TEST_/__TEST_Z_z5_manage_pool_tier_filetest.gnoA b/staker/_TEST_/__TEST_Z_z5_manage_pool_tier_filetest.gnoA index 81933262..8b068819 100644 --- a/staker/_TEST_/__TEST_Z_z5_manage_pool_tier_filetest.gnoA +++ b/staker/_TEST_/__TEST_Z_z5_manage_pool_tier_filetest.gnoA @@ -26,6 +26,7 @@ import ( var ( gsa std.Address = consts.GNOSWAP_ADMIN + ira std.Address = consts.INTERNAL_REWARD_ACCOUNT fooPath string = "gno.land/r/demo/foo" barPath string = "gno.land/r/demo/bar" @@ -48,6 +49,16 @@ var ( t *testing.T ) +// Realms to mock frames +var ( + gsaRealm = std.NewUserRealm(gsa) + iraRealm = std.NewUserRealm(ira) + + posRealm = std.NewCodeRealm(consts.POSITION_PATH) + rouRealm = std.NewCodeRealm(consts.ROUTER_PATH) + stkRealm = std.NewCodeRealm(consts.STAKER_PATH) +) + type FooToken struct{} func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) { @@ -189,7 +200,9 @@ func ugnotBalanceOf(addr std.Address) uint64 { func init() { // TOKEN REGISTER - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) + std.TestSetOrigCaller(gsa) + pl.RegisterGRC20Interface("gno.land/r/demo/foo", FooToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/bar", BarToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{}) @@ -224,7 +237,7 @@ func main() { } func createPool() { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*0) std.TestSkipHeights(1) @@ -234,7 +247,7 @@ func createPool() { } func setPoolTier() { - std.TestSetPrevAddr(consts.GNOSWAP_ADMIN) + std.TestSetRealm(gsaRealm) sr.SetPoolTier("gno.land/r/demo/bar:gno.land/r/demo/qux:500", 2) poolTier := sr.GetPoolWithTiers()["gno.land/r/demo/bar:gno.land/r/demo/qux:500"] @@ -244,7 +257,7 @@ func setPoolTier() { } func changePoolTier() { - std.TestSetPrevAddr(consts.GNOSWAP_ADMIN) + std.TestSetRealm(gsaRealm) sr.ChangePoolTier("gno.land/r/demo/bar:gno.land/r/demo/qux:500", 3) poolTier := sr.GetPoolWithTiers()["gno.land/r/demo/bar:gno.land/r/demo/qux:500"] @@ -254,7 +267,7 @@ func changePoolTier() { } func removePoolTier() { - std.TestSetPrevAddr(consts.GNOSWAP_ADMIN) + std.TestSetRealm(gsaRealm) sr.RemovePoolTier("gno.land/r/demo/bar:gno.land/r/demo/qux:500") _, exist := sr.GetPoolWithTiers()["gno.land/r/demo/bar:gno.land/r/demo/qux:500"] diff --git a/staker/_TEST_/__TEST_staker_collect_reward_test.gnoA b/staker/_TEST_/__TEST_staker_collect_reward_test.gnoA index 9c25bccd..0cc2cbb6 100644 --- a/staker/_TEST_/__TEST_staker_collect_reward_test.gnoA +++ b/staker/_TEST_/__TEST_staker_collect_reward_test.gnoA @@ -34,7 +34,7 @@ func init() { } func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) pl.CreatePool(barPath, quxPath, 500, "130621891405341611593710811006") // tick 10_000 ≈ x2.7 @@ -44,7 +44,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestPositionMint01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -72,13 +72,13 @@ func TestPositionMint01(t *testing.T) { shouldEQ(t, amount1, "1000") // approve nft to staker - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(lpTokenId)) std.TestSkipHeights(1) } func TestPositionMint02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -106,13 +106,13 @@ func TestPositionMint02(t *testing.T) { shouldEQ(t, amount1, "5000") // approve nft to staker - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(lpTokenId)) std.TestSkipHeights(1) } func TestCreateExternalIncentive(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.STAKER_ADDR), uint64(10_000_000_000)) std.TestSkipHeights(1) @@ -135,7 +135,7 @@ func TestCreateExternalIncentive(t *testing.T) { } func TestStakeToken01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) StakeToken(1) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 1} {poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {amount0 368} {amount1 1000}]} @@ -146,7 +146,7 @@ func TestStakeToken01(t *testing.T) { } func TestStakeToken02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) StakeToken(2) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 2} {poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {amount0 3979} {amount1 5000}]} @@ -157,7 +157,7 @@ func TestStakeToken02(t *testing.T) { } func TestCollectReward(t *testing.T) { - std.TestSetPrevAddr(consts.INTERNAL_REWARD_ACCOUNT) + std.TestSetRealm(iraRealm) gns.Approve(a2u(consts.STAKER_ADDR), consts.UINT64_MAX) // internal reward distribution std.TestSkipHeights(1) @@ -166,7 +166,7 @@ func TestCollectReward(t *testing.T) { std.TestSkipHeights(1) shouldEQ(t, gnsOld, 500000000000000) - std.TestSetPrevRealm(consts.STAKER_PATH) + std.TestSetRealm(stkRealm) std.TestSetOrigCaller(gsa) CollectReward(1) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker handleRewardFee [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenPath gno.land/r/demo/gns} {p_internal true} {feeAmount 4}]} @@ -180,7 +180,7 @@ func TestCollectReward(t *testing.T) { } func TestUnstakeToken01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) std.TestSkipHeights(400) // spend more time UnstakeToken(1) // GNFT tokenId @@ -200,7 +200,7 @@ func TestUnstakeToken01(t *testing.T) { } func TestUnstakeToken02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) UnstakeToken(2) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker handleRewardFee [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenPath gno.land/r/demo/obl} {p_internal false} {feeAmount 300}]} // --- event: {GNOSWAP gno.land/r/demo/staker CollectReward [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 2} {poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {rewardToken gno.land/r/demo/obl} {recipient g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {amount 29792}]} @@ -218,7 +218,7 @@ func TestUnstakeToken02(t *testing.T) { } func TestEndExternalIncentive(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) std.TestSkipHeights(9999999) EndExternalIncentive(std.GetOrigCaller().String(), "gno.land/r/demo/bar:gno.land/r/demo/qux:500", "gno.land/r/demo/obl") // use same parameter as CreateExternalIncentive() // --- event: {GNOSWAP gno.land/r/demo/staker EndExternalIncentive [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {p_rewardToken gno.land/r/demo/obl} {p_refundee g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {end_by g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {refund_amount 0}]} diff --git a/staker/_TEST_/__TEST_staker_external_test.gnoA b/staker/_TEST_/__TEST_staker_external_test.gnoA index 2e41b892..66eee162 100644 --- a/staker/_TEST_/__TEST_staker_external_test.gnoA +++ b/staker/_TEST_/__TEST_staker_external_test.gnoA @@ -34,7 +34,7 @@ func init() { } func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*3) std.TestSkipHeights(1) @@ -49,7 +49,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestMintBarQux500_1(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -77,7 +77,7 @@ func TestMintBarQux500_1(t *testing.T) { } func TestMintBarBaz100_2(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -105,7 +105,7 @@ func TestMintBarBaz100_2(t *testing.T) { } func TestMintBarBaz100_3(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -133,7 +133,7 @@ func TestMintBarBaz100_3(t *testing.T) { } func TestCreateExternalIncentive(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.STAKER_ADDR), uint64(100_000_000)) std.TestSkipHeights(1) @@ -150,7 +150,7 @@ func TestCreateExternalIncentive(t *testing.T) { } func TestStakeExternal_2(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(2)) StakeToken(2) // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 2} {poolPath gno.land/r/demo/bar:gno.land/r/demo/baz:100} {amount0 100000} {amount1 100000}]} @@ -162,7 +162,7 @@ func TestStakeExternal_2(t *testing.T) { } func TestStakeExternal_3(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(3)) StakeToken(3) // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 3} {poolPath gno.land/r/demo/bar:gno.land/r/demo/baz:100} {amount0 100000} {amount1 100000}]} @@ -174,7 +174,7 @@ func TestStakeExternal_3(t *testing.T) { } func TestCollectExternalReward_2(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // before claim oblOld := obl.BalanceOf(a2u(gsa)) @@ -192,7 +192,7 @@ func TestCollectExternalReward_2(t *testing.T) { } func TestCollectExternalReward_3(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // before claim oblOld := obl.BalanceOf(a2u(gsa)) diff --git a/staker/_TEST_/__TEST_staker_full_test.gnoA b/staker/_TEST_/__TEST_staker_full_test.gnoA index 4ecc3d4f..bf18f0bc 100644 --- a/staker/_TEST_/__TEST_staker_full_test.gnoA +++ b/staker/_TEST_/__TEST_staker_full_test.gnoA @@ -35,7 +35,7 @@ func init() { } func TestPoolCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -47,7 +47,7 @@ func TestPoolCreatePool(t *testing.T) { } func TestPositionMint01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -75,13 +75,13 @@ func TestPositionMint01(t *testing.T) { shouldEQ(t, amount1, "1000") // approve nft to staker for staking - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(lpTokenId)) std.TestSkipHeights(1) } func TestPositionMint02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -109,13 +109,13 @@ func TestPositionMint02(t *testing.T) { shouldEQ(t, amount1, "5000") // approve nft to staker - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(lpTokenId)) std.TestSkipHeights(1) } func TestCreateExternalIncentive(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.STAKER_ADDR), 10_000_000_000) std.TestSkipHeights(1) @@ -137,7 +137,7 @@ func TestCreateExternalIncentive(t *testing.T) { } func TestStakeToken01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) StakeToken(1) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 1} {poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {amount0 368} {amount1 1000}]} @@ -148,7 +148,7 @@ func TestStakeToken01(t *testing.T) { } func TestStakeToken02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) StakeToken(2) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 2} {poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {amount0 3979} {amount1 5000}]} @@ -159,7 +159,7 @@ func TestStakeToken02(t *testing.T) { } func TestMintAndStake(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -213,7 +213,7 @@ func TestApiGetStakes(t *testing.T) { } func TestCollectReward(t *testing.T) { - std.TestSetPrevAddr(consts.INTERNAL_REWARD_ACCOUNT) + std.TestSetRealm(iraRealm) gns.Approve(a2u(consts.STAKER_ADDR), consts.UINT64_MAX) // internal reward distribution std.TestSkipHeights(1) @@ -221,7 +221,7 @@ func TestCollectReward(t *testing.T) { gnsOld := gns.BalanceOf(a2u(gsa)) shouldEQ(t, gnsOld, 500000000000000) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) CollectReward(1) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker handleRewardFee [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenPath gno.land/r/demo/obl} {p_internal false} {feeAmount 97}]} // --- event: {GNOSWAP gno.land/r/demo/staker CollectReward [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 1} {poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {rewardToken gno.land/r/demo/obl} {recipient g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {amount 9663}]} @@ -235,7 +235,7 @@ func TestCollectReward(t *testing.T) { } func TestUnstakeToken01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) UnstakeToken(1) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker handleRewardFee [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenPath gno.land/r/demo/obl} {p_internal false} {feeAmount 0}]} // --- event: {GNOSWAP gno.land/r/demo/staker CollectReward [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 1} {poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {rewardToken gno.land/r/demo/obl} {recipient g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {amount 50}]} @@ -253,7 +253,7 @@ func TestUnstakeToken01(t *testing.T) { } func TestUnstakeToken02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) UnstakeToken(2) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker handleRewardFee [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenPath gno.land/r/demo/obl} {p_internal false} {feeAmount 22}]} // --- event: {GNOSWAP gno.land/r/demo/staker CollectReward [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 2} {poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {rewardToken gno.land/r/demo/obl} {recipient g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {amount 2246}]} diff --git a/staker/_TEST_/__TEST_staker_get_test.gnoA b/staker/_TEST_/__TEST_staker_get_test.gnoA index b8470f25..cbe59c30 100644 --- a/staker/_TEST_/__TEST_staker_get_test.gnoA +++ b/staker/_TEST_/__TEST_staker_get_test.gnoA @@ -19,7 +19,7 @@ import ( ) func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(2) @@ -31,7 +31,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestPositionMint01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -59,13 +59,13 @@ func TestPositionMint01(t *testing.T) { shouldEQ(t, amount1, "1000") // approve nft to staker - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(lpTokenId)) std.TestSkipHeights(1) } func TestPositionMint02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -93,13 +93,13 @@ func TestPositionMint02(t *testing.T) { shouldEQ(t, amount1, "5000") // approve nft to staker - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(lpTokenId)) std.TestSkipHeights(1) } func TestCreateExternalIncentive(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.STAKER_ADDR), uint64(10_000_000_000)) std.TestSkipHeights(1) @@ -122,7 +122,7 @@ func TestCreateExternalIncentive(t *testing.T) { } func TestStakeToken01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) StakeToken(1) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 1} {poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {amount0 368} {amount1 1000}]} @@ -133,7 +133,7 @@ func TestStakeToken01(t *testing.T) { } // func TestStakeToken02(t *testing.T) { -// std.TestSetPrevAddr(gsa) +// std.TestSetRealm(gsaRealm) // StakeToken(2) // GNFT tokenId // std.TestSkipHeights(1) diff --git a/staker/_TEST_/__TEST_staker_internal_test.gnoA b/staker/_TEST_/__TEST_staker_internal_test.gnoA index 32ca2a7b..24cbfccd 100644 --- a/staker/_TEST_/__TEST_staker_internal_test.gnoA +++ b/staker/_TEST_/__TEST_staker_internal_test.gnoA @@ -34,7 +34,7 @@ func init() { } func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE*3) std.TestSkipHeights(1) @@ -52,7 +52,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestMintBarQux500(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -81,7 +81,7 @@ func TestMintBarQux500(t *testing.T) { } func TestMintBarBaz100(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -109,7 +109,7 @@ func TestMintBarBaz100(t *testing.T) { } func TestMintFooQux500(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -138,7 +138,7 @@ func TestMintFooQux500(t *testing.T) { } func TestStakeInternalTier1(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(1)) StakeToken(1) // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 1} {poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {amount0 36790} {amount1 100000}]} @@ -150,7 +150,7 @@ func TestStakeInternalTier1(t *testing.T) { } func TestStakeInternalTier2(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(2)) StakeToken(2) // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 2} {poolPath gno.land/r/demo/bar:gno.land/r/demo/baz:100} {amount0 100000} {amount1 100000}]} @@ -162,7 +162,7 @@ func TestStakeInternalTier2(t *testing.T) { } func TestCollectRewardToken1(t *testing.T) { - std.TestSetPrevAddr(consts.INTERNAL_REWARD_ACCOUNT) + std.TestSetRealm(iraRealm) gns.Approve(a2u(consts.STAKER_ADDR), consts.UINT64_MAX) // internal reward distribution std.TestSkipHeights(1) @@ -171,7 +171,7 @@ func TestCollectRewardToken1(t *testing.T) { shouldEQ(t, gnsOld, 500000000000000) std.TestSkipHeights(6307200) // 5 * 6307200 = 31536000second = 1 year - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) CollectReward(1) // --- event: {GNOSWAP gno.land/r/demo/staker handleRewardFee [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenPath gno.land/r/demo/gns} {p_internal true} {feeAmount 173448137}]} // --- event: {GNOSWAP gno.land/r/demo/staker CollectReward [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 1} {poolPath gno.land/r/demo/bar:gno.land/r/demo/qux:500} {rewardToken gno.land/r/demo/gns} {recipient g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {amount 17171365613}]} diff --git a/staker/_TEST_/__TEST_staker_manage_pool_tiers_test.gnoA b/staker/_TEST_/__TEST_staker_manage_pool_tiers_test.gnoA index 04f04f50..80291393 100644 --- a/staker/_TEST_/__TEST_staker_manage_pool_tiers_test.gnoA +++ b/staker/_TEST_/__TEST_staker_manage_pool_tiers_test.gnoA @@ -12,7 +12,7 @@ import ( ) func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) diff --git a/staker/_TEST_/__TEST_staker_mint_and_stake_test.gnoA b/staker/_TEST_/__TEST_staker_mint_and_stake_test.gnoA index a8f11afa..e9635ff0 100644 --- a/staker/_TEST_/__TEST_staker_mint_and_stake_test.gnoA +++ b/staker/_TEST_/__TEST_staker_mint_and_stake_test.gnoA @@ -30,7 +30,7 @@ func init() { } func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -45,7 +45,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestMintAndStakeGRC20Pair(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -70,7 +70,7 @@ func TestMintAndStakeGRC20Pair(t *testing.T) { } func TestMintAndStakeNative(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // MINT wugnot.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // MINT @@ -124,17 +124,17 @@ func TestMintAndStakeNative(t *testing.T) { /* func TestPositionCollectFee(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) pn.CollectFee(1) // lpTokenId std.TestSkipHeights(1) } func TestCollectReward(t *testing.T) { // internal reward distribution - std.TestSetPrevAddr(consts.INTERNAL_REWARD_ACCOUNT) + std.TestSetRealm(iraRealm) gns.Approve(a2u(consts.STAKER_ADDR), consts.UINT64_MAX) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) CollectReward(1) // lpTokenId std.TestSkipHeights(1) } @@ -143,7 +143,7 @@ func TestUnstakeToken(t *testing.T) { ownerOfLp1 := gnft.OwnerOf(tid(1)) shouldEQ(t, ownerOfLp1, a2u(consts.STAKER_ADDR)) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) UnstakeToken(1) // lpTokenId std.TestSkipHeights(1) diff --git a/staker/_TEST_/__TEST_staker_native_create_collect_unstake_test.gnoA b/staker/_TEST_/__TEST_staker_native_create_collect_unstake_test.gnoA index 998b1466..a9633d3b 100644 --- a/staker/_TEST_/__TEST_staker_native_create_collect_unstake_test.gnoA +++ b/staker/_TEST_/__TEST_staker_native_create_collect_unstake_test.gnoA @@ -31,7 +31,7 @@ func init() { } func TestPoolInitCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -41,7 +41,7 @@ func TestPoolInitCreatePool(t *testing.T) { } func TestPositionMintNative01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // MINT wugnot.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // MINT @@ -88,7 +88,7 @@ func TestPositionMintNative01(t *testing.T) { } func TestPositionMintNative02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // MINT wugnot.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) // MINT @@ -136,7 +136,7 @@ func TestPositionMintNative02(t *testing.T) { } func TestCreateExternalIncentive(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) // prepare 10000000000 ugnot std.TestIssueCoins(gsa, std.Coins{{"ugnot", 10_000_000_000}}) @@ -173,7 +173,7 @@ func TestCreateExternalIncentive(t *testing.T) { func TestStakeToken01(t *testing.T) { // approve nft to staker for staking - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(1)) std.TestSkipHeights(1) @@ -188,7 +188,7 @@ func TestStakeToken01(t *testing.T) { func TestStakeToken02(t *testing.T) { // approve nft to staker for staking - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(2)) std.TestSkipHeights(1) @@ -202,7 +202,7 @@ func TestStakeToken02(t *testing.T) { } func TestCollectReward01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) std.TestSkipHeights(1000) shouldEQ(t, wugnot.BalanceOf(a2u(gsa)), 0) @@ -220,14 +220,14 @@ func TestCollectReward01(t *testing.T) { } func TestUnstakeToken02(t *testing.T) { - std.TestSetPrevAddr(consts.INTERNAL_REWARD_ACCOUNT) + std.TestSetRealm(iraRealm) gns.Approve(a2u(consts.STAKER_ADDR), consts.UINT64_MAX) // internal reward distribution std.TestSkipHeights(335) // skip times shouldEQ(t, wugnot.BalanceOf(a2u(gsa)), 0) shouldEQ(t, ugnotBalanceOf(gsa), 100641583) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) wugnot.Approve(a2u(consts.STAKER_ADDR), consts.UINT64_MAX) // UNWRAP UnstakeToken(2) // GNFT tokenId diff --git a/staker/_TEST_/__TEST_staker_one_increase_external_test.gnoA b/staker/_TEST_/__TEST_staker_one_increase_external_test.gnoA index 1e1557d6..b51c5cc8 100644 --- a/staker/_TEST_/__TEST_staker_one_increase_external_test.gnoA +++ b/staker/_TEST_/__TEST_staker_one_increase_external_test.gnoA @@ -34,7 +34,7 @@ func init() { } func TestPoolCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -46,7 +46,7 @@ func TestPoolCreatePool(t *testing.T) { } func TestPositionMint01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -74,13 +74,13 @@ func TestPositionMint01(t *testing.T) { shouldEQ(t, amount1, "368") // approve nft to staker for staking - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(lpTokenId)) std.TestSkipHeights(1) } func TestPositionMint02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -108,13 +108,13 @@ func TestPositionMint02(t *testing.T) { shouldEQ(t, amount1, "3979") // approve nft to staker - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(lpTokenId)) std.TestSkipHeights(1) } func TestCreateExternalIncentive(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.STAKER_ADDR), 10_000_000_000) std.TestSkipHeights(1) @@ -136,7 +136,7 @@ func TestCreateExternalIncentive(t *testing.T) { } func TestStakeToken01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) StakeToken(1) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 1} {poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500} {amount0 1000} {amount1 368}]} @@ -147,7 +147,7 @@ func TestStakeToken01(t *testing.T) { } func TestStakeToken02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) StakeToken(2) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 2} {poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500} {amount0 5000} {amount1 3979}]} @@ -190,11 +190,11 @@ func TestApiGetRewardTokens(t *testing.T) { } func TestUnstakeToken01(t *testing.T) { - std.TestSetPrevAddr(consts.INTERNAL_REWARD_ACCOUNT) + std.TestSetRealm(iraRealm) gns.Approve(a2u(consts.STAKER_ADDR), consts.UINT64_MAX) // internal reward distribution std.TestSkipHeights(350) - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) UnstakeToken(1) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker handleRewardFee [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenPath gno.land/r/demo/obl} {p_internal false} {feeAmount 7}]} // --- event: {GNOSWAP gno.land/r/demo/staker CollectReward [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 1} {poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500} {rewardToken gno.land/r/demo/obl} {recipient g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {amount 756}]} @@ -212,7 +212,7 @@ func TestUnstakeToken01(t *testing.T) { } func TestUnstakeToken02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) UnstakeToken(2) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker handleRewardFee [{m_callType INDIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenPath gno.land/r/demo/obl} {p_internal false} {feeAmount 53}]} // --- event: {GNOSWAP gno.land/r/demo/staker CollectReward [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 2} {poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500} {rewardToken gno.land/r/demo/obl} {recipient g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {amount 5249}]} diff --git a/staker/_TEST_/__TEST_staker_rpc_api_test.gnoA b/staker/_TEST_/__TEST_staker_rpc_api_test.gnoA index adfdf81c..df439080 100644 --- a/staker/_TEST_/__TEST_staker_rpc_api_test.gnoA +++ b/staker/_TEST_/__TEST_staker_rpc_api_test.gnoA @@ -34,7 +34,7 @@ func init() { } func TestPoolCreatePool(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE) std.TestSkipHeights(1) @@ -49,7 +49,7 @@ func TestPoolCreatePool(t *testing.T) { } func TestPositionMintFooBar01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -77,13 +77,13 @@ func TestPositionMintFooBar01(t *testing.T) { shouldEQ(t, amount1, "368") // approve nft to staker for staking - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(lpTokenId)) std.TestSkipHeights(1) } func TestPositionMintFooBar02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -111,13 +111,13 @@ func TestPositionMintFooBar02(t *testing.T) { shouldEQ(t, amount1, "3979") // approve nft to staker - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(lpTokenId)) std.TestSkipHeights(1) } func TestPositionMintBazQux01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) qux.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) std.TestSkipHeights(2) @@ -145,13 +145,13 @@ func TestPositionMintBazQux01(t *testing.T) { shouldEQ(t, amount1, "5000") // approve nft to staker - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) gnft.Approve(a2u(GetOrigPkgAddr()), tid(lpTokenId)) std.TestSkipHeights(1) } func TestCreateExternalIncentive(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) obl.Approve(a2u(consts.STAKER_ADDR), 10_000_000_000) std.TestSkipHeights(1) @@ -173,7 +173,7 @@ func TestCreateExternalIncentive(t *testing.T) { } func TestStakeToken01(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) StakeToken(1) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 1} {poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500} {amount0 1000} {amount1 368}]} @@ -184,7 +184,7 @@ func TestStakeToken01(t *testing.T) { } func TestStakeToken02(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) StakeToken(2) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 2} {poolPath gno.land/r/demo/bar:gno.land/r/demo/foo:500} {amount0 5000} {amount1 3979}]} @@ -195,7 +195,7 @@ func TestStakeToken02(t *testing.T) { } func TestStakeToken03(t *testing.T) { - std.TestSetPrevAddr(gsa) + std.TestSetRealm(gsaRealm) StakeToken(3) // GNFT tokenId // --- event: {GNOSWAP gno.land/r/demo/staker StakeToken [{m_callType DIRECT} {m_origCaller g13f63ua8uhmuf9mgc0x8zfz04yrsaqh7j78vcgq} {m_prevRealm } {p_tokenId 3} {poolPath gno.land/r/demo/baz:gno.land/r/demo/qux:500} {amount0 3979} {amount1 5000}]}