Skip to content

Commit

Permalink
outpost user test strictly uses outpost API directly
Browse files Browse the repository at this point in the history
  • Loading branch information
BiPhan4 committed Oct 30, 2024
1 parent ebc9114 commit 0b46104
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 43 deletions.
41 changes: 28 additions & 13 deletions e2e/interchaintest/logs/test.log
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
INFO: 2024/10/29 16:26:32 The sender of instantiate is wasmd-localwasm-1-wrj
INFO: 2024/10/29 16:26:44 [0x1400137c100]
INFO: 2024/10/29 16:27:44 outpost user address is: wasm1qg5ega6dykkxc307y25pecuufrjkxkaggkkxh7nad0vhyhtuhw3sq29c3m

INFO: 2024/10/29 16:27:49 The outpost address is: wasm1yyca08xqdgvjz0psg56z67ejh9xms6l436u8y58m82npdqqhmmtqas0cl7

INFO: 2024/10/29 16:27:49 The outpost owner is: data:"\"wasm1qg5ega6dykkxc307y25pecuufrjkxkaggkkxh7nad0vhyhtuhw3sq29c3m\""

INFO: 2024/10/29 16:28:00 The outpost state is: &{{jkl13hqx99r8hj2hlxafmp3q9naa86ynjkhdnd4y0myu3tn8pshruywqxhh7h0 channel-1} true}

INFO: 2024/10/29 16:28:00 The outpost jkl (ica) address is: jkl13hqx99r8hj2hlxafmp3q9naa86ynjkhdnd4y0myu3tn8pshruywqxhh7h0

INFO: 2024/10/29 16:28:13 data:"\"{\\\"description\\\": \\\"outpost user note\\\", \\\"additional_info\\\": \\\"placeholder\\\"}\""
INFO: 2024/10/30 13:04:57 Wasmd First light client is
INFO: 2024/10/30 13:04:57 [
{
"client_id": "07-tendermint-0",
"client_state": {
"chain_id": "puppy-1"
}
},
{
"client_id": "09-localhost",
"client_state": {
"chain_id": ""
}
}
]
INFO: 2024/10/30 13:04:57 Wasmd Second light client is
INFO: 2024/10/30 13:04:57 null
INFO: 2024/10/30 13:04:57 jackal first light client is
INFO: 2024/10/30 13:04:57 [
{
"client_id": "07-tendermint-0",
"client_state": {
"chain_id": "localwasm-1"
}
}
]
INFO: 2024/10/30 13:04:57 jackal second light client is
INFO: 2024/10/30 13:04:57 null
33 changes: 3 additions & 30 deletions e2e/interchaintest/outpost_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,9 @@ func (s *ContractTestSuite) TestOutpostUser() {
[]proto.Message{postFileMsg}, nil, nil, typeURL,
)

// NOTE: Double check this before calling it
innerOutpostMsg := outpostuser.ExecuteMsg_CallOutpost{
Msg: &sendStargateMsg,
}

outpostUserMsg := outpostuser.ExecuteMsg{
CallOutpost: &innerOutpostMsg,
}

// WARNING NOTE: Only the owner of the outpost can call it.
// The below execution doesn't work because cross contract calls are made with the calling contract's address as the sender
// Unfortunately, UserA is set as the outpost owner because UserA instantiated it
// Seems there's no way around this but to have the outpost user contract also instantiate the outpost

// We know 'instantiate2' works on canine-chain, so perhaps we can use that and avoid having to use a callback
Res, err := s.ChainA.ExecuteContract(ctx, s.UserA.KeyName(), outpostUserContract, outpostUserMsg.ToString(), "--gas", "500000")
Res2, err := s.ChainA.ExecuteContract(ctx, s.UserA.KeyName(), outpostUserContract, sendStargateMsg.ToString(), "--gas", "500000")
s.Require().NoError(err)
fmt.Println(Res)
fmt.Println(Res2)

saveNoteMsg := outpostuser.ExecuteMsg{
SaveNote: &outpostuser.ExecuteMsg_SaveNote{
Expand All @@ -164,23 +149,11 @@ func (s *ContractTestSuite) TestOutpostUser() {
// We guarantee that multiple execute messages can be broadcast in the same transaction with the cosmos-sdk.
// We recommend building this out on testnet.

// Query a PubKey
// Query For the note
pubRes, pubErr := testsuite.GetNote(ctx, s.ChainA, s.UserA.FormattedAddress(), outpostUserContract)
logger.LogInfo(pubRes)
s.Require().NoError(pubErr)

// Call the API directly

postFileMsg.Note = `{"description": "outpost user note from API directly", "additional_info": "NONE"}`

sendStargateMsg = testtypes.NewExecuteMsg_SendCosmosMsgs_FromProto(
[]proto.Message{postFileMsg}, nil, nil, typeURL,
)

Res2, err := s.ChainA.ExecuteContract(ctx, s.UserA.KeyName(), outpostUserContract, sendStargateMsg.ToString(), "--gas", "500000")
s.Require().NoError(err)
fmt.Println(Res2)

},
)
// implement mock query server
Expand Down

0 comments on commit 0b46104

Please sign in to comment.