-
Notifications
You must be signed in to change notification settings - Fork 590
/
testing_hooks.go
42 lines (32 loc) · 1.19 KB
/
testing_hooks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package testutils
import (
// external libraries
sdk "github.com/cosmos/cosmos-sdk/types"
// ibc-go
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported"
ibchooks "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks"
)
var (
_ ibchooks.Hooks = TestRecvOverrideHooks{}
_ ibchooks.Hooks = TestRecvBeforeAfterHooks{}
)
type Status struct {
OverrideRan bool
BeforeRan bool
AfterRan bool
}
// Recv
type TestRecvOverrideHooks struct{ Status *Status }
func (t TestRecvOverrideHooks) OnRecvPacketOverride(im ibchooks.IBCMiddleware, ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) ibcexported.Acknowledgement {
t.Status.OverrideRan = true
ack := im.App.OnRecvPacket(ctx, packet, relayer)
return ack
}
type TestRecvBeforeAfterHooks struct{ Status *Status }
func (t TestRecvBeforeAfterHooks) OnRecvPacketBeforeHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) {
t.Status.BeforeRan = true
}
func (t TestRecvBeforeAfterHooks) OnRecvPacketAfterHook(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, ack ibcexported.Acknowledgement) {
t.Status.AfterRan = true
}