diff --git a/e2e/interchaintest/Readme.md b/e2e/interchaintest/Readme.md index 4dca086..a27f509 100644 --- a/e2e/interchaintest/Readme.md +++ b/e2e/interchaintest/Readme.md @@ -14,6 +14,8 @@ go test -v . -run TestWithFactoryTestSuite -testify.m TestMasterMigration -timeo go test -v . -run TestWithContractTestSuite -testify.m TestIcaContractExecutionTestWithFiletree -timeout 12h +go test -v . -run TestWithContractTestSuite -testify.m TestReOpenOrderedChannel -timeout 12h + go test -v . -run TestWithContractTestSuite -testify.m TestIcaContractExecutionTestWithOwnership -timeout 12h go test -v . -run TestWithContractTestSuite -testify.m TestIcaContractExecutionTestWithBuyStorage -timeout 12h diff --git a/e2e/interchaintest/logs/test.log b/e2e/interchaintest/logs/test.log index 83cf494..a12ebe6 100644 --- a/e2e/interchaintest/logs/test.log +++ b/e2e/interchaintest/logs/test.log @@ -1,17 +1,6 @@ -INFO: 2024/10/21 15:31:56 Factory contract Info is: address:"wasm1wug8sewp6cedgkmrmvhl3lf3tulagm9hnvy8p0rppz9yjw0g4wtqhs9hr8" contract_info: ibc_port_id:"wasm.wasm1wug8sewp6cedgkmrmvhl3lf3tulagm9hnvy8p0rppz9yjw0g4wtqhs9hr8" > - -INFO: 2024/10/21 15:31:56 Admin of factory is: wasm13w0fse6k9tvrq6zn68smdl6ln4s7kmh9fvq8ag - -INFO: 2024/10/21 15:32:00 outpostContractInfo is: address:"wasm1suhgf5svhu4usrurvxzlgn54ksxmn8gljarjtxqnapv8kjnp4nrss5maay" contract_info: ibc_port_id:"wasm.wasm1suhgf5svhu4usrurvxzlgn54ksxmn8gljarjtxqnapv8kjnp4nrss5maay" > - -INFO: 2024/10/21 15:32:00 Admin of user A's outpost is: wasm1wug8sewp6cedgkmrmvhl3lf3tulagm9hnvy8p0rppz9yjw0g4wtqhs9hr8 - -INFO: 2024/10/21 15:32:00 outpostContractState is: data:"{\"admin\":\"wasm1wug8sewp6cedgkmrmvhl3lf3tulagm9hnvy8p0rppz9yjw0g4wtqhs9hr8\",\"allow_channel_open_init\":true}" - -INFO: 2024/10/21 15:32:00 Owner of user A's outpost is: wasm13w0fse6k9tvrq6zn68smdl6ln4s7kmh9fvq8ag - -INFO: 2024/10/21 15:32:00 Mapped outpost address is: wasm1suhgf5svhu4usrurvxzlgn54ksxmn8gljarjtxqnapv8kjnp4nrss5maay - -INFO: 2024/10/21 15:32:39 factory map is: data:"[[\"wasm125gw73kajruy5e9xcnpjx60nh6md4gjfvr6ees\",\"wasm1yyca08xqdgvjz0psg56z67ejh9xms6l436u8y58m82npdqqhmmtqas0cl7\"],[\"wasm13w0fse6k9tvrq6zn68smdl6ln4s7kmh9fvq8ag\",\"wasm1suhgf5svhu4usrurvxzlgn54ksxmn8gljarjtxqnapv8kjnp4nrss5maay\"]]" -INFO: 2024/10/21 15:32:39 Mapping 0: [wasm125gw73kajruy5e9xcnpjx60nh6md4gjfvr6ees wasm1yyca08xqdgvjz0psg56z67ejh9xms6l436u8y58m82npdqqhmmtqas0cl7] -INFO: 2024/10/21 15:32:39 Mapping 1: [wasm13w0fse6k9tvrq6zn68smdl6ln4s7kmh9fvq8ag wasm1suhgf5svhu4usrurvxzlgn54ksxmn8gljarjtxqnapv8kjnp4nrss5maay] +INFO: 2024/10/22 13:59:08 The sender of instantiate is wasmd-localwasm-1-abm +INFO: 2024/10/22 13:59:19 [0x1400135e000] +INFO: 2024/10/22 14:00:33 +INFO: 2024/10/22 14:01:06 [{STATE_CLOSED ORDER_ORDERED {wasm.wasm14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s0phg4d channel-0} [connection-0] {"version":"ics27-1","controller_connection_id":"connection-0","host_connection_id":"connection-0","address":"jkl1zh4wgjy33shq4p0hrga7ayn5nzv9pmtcca9h3p4eplnnn7h7xtxqhmfyrd","encoding":"proto3","tx_type":"sdk_multi_msg"} icahost channel-0} {STATE_OPEN ORDER_ORDERED {wasm.wasm14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s0phg4d channel-1} [connection-0] {"version":"ics27-1","controller_connection_id":"connection-0","host_connection_id":"connection-0","address":"jkl1zh4wgjy33shq4p0hrga7ayn5nzv9pmtcca9h3p4eplnnn7h7xtxqhmfyrd","encoding":"proto3","tx_type":"sdk_multi_msg"} icahost channel-1}] +INFO: 2024/10/22 14:01:06 +INFO: 2024/10/22 14:01:07 channel-1 diff --git a/e2e/interchaintest/re_open_channel_test.go b/e2e/interchaintest/re_open_channel_test.go index cd92532..5494d88 100644 --- a/e2e/interchaintest/re_open_channel_test.go +++ b/e2e/interchaintest/re_open_channel_test.go @@ -112,6 +112,20 @@ func (s *ContractTestSuite) TestReOpenOrderedChannel() { }) s.Run("TestReOpenOrderedChannelAndPostKey", func() { + + // Ensure that only the owner can re-open the channel + + badCreateChannelMsg := testtypes.ExecuteMsg{ + CreateChannel: &testtypes.ExecuteMsg_CreateChannel{ + ChannelOpenInitOptions: nil, // consequence of not putting open init options?... + }, + } + + executeErr := s.Contract.Execute(ctx, s.UserA2.KeyName(), badCreateChannelMsg, "--gas", "500000") + + expectedCreationErrorMsg := fmt.Sprintf("error in transaction (code: 5): failed to execute message; message index: 0: Caller is not the contract's current owner: execute wasm contract failed") + s.Require().EqualError(executeErr, expectedCreationErrorMsg) + // Reopen the channel: createChannelMsg := testtypes.ExecuteMsg{ @@ -119,9 +133,8 @@ func (s *ContractTestSuite) TestReOpenOrderedChannel() { ChannelOpenInitOptions: nil, // consequence of not putting open init options?... }, } - // contractAddr, err := s.ChainA.InstantiateContract(ctx, s.UserA.KeyName(), codeId, instantiateMsg, false, "--gas", "500000", "--admin", s.UserA.KeyName()) - executeErr := s.Contract.Execute(ctx, wasmdUser.KeyName(), createChannelMsg, "--gas", "500000") + executeErr = s.Contract.Execute(ctx, wasmdUser.KeyName(), createChannelMsg, "--gas", "500000") s.Require().NoError(executeErr) // Wait for the channel to get set up diff --git a/src/contract.rs b/src/contract.rs index 52eb511..3d4424d 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -179,8 +179,6 @@ mod execute { ) -> Result { cw_ownable::assert_owner(deps.storage, &info.sender)?; - // TODO: make this more readable and less confusing? - // TODO: get rid of 'state::' usage let options = if let Some(new_options) = options { state::CHANNEL_OPEN_INIT_OPTIONS.save(deps.storage, &new_options)?; new_options @@ -190,9 +188,6 @@ mod execute { .ok_or(ContractError::NoChannelInitOptions)? }; - // WARNING - // TODO: ponder - I think that 'assert_owner' ensures that only the only can call create_channel and update - // 'ALLOW_CHANNEL_OPEN INIT'. It's also updated during instantiation and the owner is set there state::ALLOW_CHANNEL_OPEN_INIT.save(deps.storage, &true)?; let ica_channel_open_init_msg = new_ica_channel_open_init_cosmos_msg(