forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to wasmvm v0.14.0-beta5 (cosmos#504)
* Bump deps and contracts to v0.14.0-beta5 * Add admin field/variants to WasmMsg handling * Compiles * Update usage of IBC Timeout in tests * Minor doc/test/Dockerfile updates Co-authored-by: Alex Peters <alpe@users.noreply.github.com>
- Loading branch information
Showing
18 changed files
with
263 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package wasm | ||
|
||
import ( | ||
wasmvmtypes "github.com/CosmWasm/wasmvm/types" | ||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" | ||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestMapToWasmVMIBCPacket(t *testing.T) { | ||
var myTimestamp uint64 = 1 | ||
specs := map[string]struct { | ||
src channeltypes.Packet | ||
exp wasmvmtypes.IBCPacket | ||
}{ | ||
"with hight timeout": { | ||
src: IBCPacketFixture(), | ||
exp: wasmvmtypes.IBCPacket{ | ||
Data: []byte("myData"), | ||
Src: wasmvmtypes.IBCEndpoint{PortID: "srcPort", ChannelID: "channel-1"}, | ||
Dest: wasmvmtypes.IBCEndpoint{PortID: "destPort", ChannelID: "channel-2"}, | ||
Sequence: 1, | ||
Timeout: wasmvmtypes.IBCTimeout{Block: &wasmvmtypes.IBCTimeoutBlock{Height: 1, Revision: 2}}, | ||
}, | ||
}, | ||
"with time timeout": { | ||
src: IBCPacketFixture(func(p *channeltypes.Packet) { | ||
p.TimeoutTimestamp = myTimestamp | ||
p.TimeoutHeight = clienttypes.Height{} | ||
}), | ||
exp: wasmvmtypes.IBCPacket{ | ||
Data: []byte("myData"), | ||
Src: wasmvmtypes.IBCEndpoint{PortID: "srcPort", ChannelID: "channel-1"}, | ||
Dest: wasmvmtypes.IBCEndpoint{PortID: "destPort", ChannelID: "channel-2"}, | ||
Sequence: 1, | ||
Timeout: wasmvmtypes.IBCTimeout{Timestamp: &myTimestamp}, | ||
}, | ||
}, "with time and height timeout": { | ||
src: IBCPacketFixture(func(p *channeltypes.Packet) { | ||
p.TimeoutTimestamp = myTimestamp | ||
}), | ||
exp: wasmvmtypes.IBCPacket{ | ||
Data: []byte("myData"), | ||
Src: wasmvmtypes.IBCEndpoint{PortID: "srcPort", ChannelID: "channel-1"}, | ||
Dest: wasmvmtypes.IBCEndpoint{PortID: "destPort", ChannelID: "channel-2"}, | ||
Sequence: 1, | ||
Timeout: wasmvmtypes.IBCTimeout{Both: &wasmvmtypes.IBCTimeoutBoth{ | ||
Block: wasmvmtypes.IBCTimeoutBlock{Height: 1, Revision: 2}, | ||
Timestamp: myTimestamp, | ||
}}, | ||
}, | ||
}, | ||
} | ||
for name, spec := range specs { | ||
t.Run(name, func(t *testing.T) { | ||
got := newIBCPacket(spec.src) | ||
assert.Equal(t, spec.exp, got) | ||
}) | ||
} | ||
} | ||
|
||
func IBCPacketFixture(mutators ...func(p *channeltypes.Packet)) channeltypes.Packet { | ||
r := channeltypes.Packet{ | ||
Sequence: 1, | ||
SourcePort: "srcPort", | ||
SourceChannel: "channel-1", | ||
DestinationPort: "destPort", | ||
DestinationChannel: "channel-2", | ||
Data: []byte("myData"), | ||
TimeoutHeight: clienttypes.Height{ | ||
RevisionHeight: 1, | ||
RevisionNumber: 2, | ||
}, | ||
TimeoutTimestamp: 0, | ||
} | ||
for _, m := range mutators { | ||
m(&r) | ||
} | ||
return r | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.