-
Notifications
You must be signed in to change notification settings - Fork 210
/
event.go
60 lines (40 loc) · 1.24 KB
/
event.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package testutil
import (
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3"
"github.com/akash-network/akash-api/go/sdkutil"
)
func ParseEvent(t testing.TB, events []abci.Event) sdkutil.Event {
t.Helper()
require.Equal(t, 1, len(events))
sev := sdk.StringifyEvent(events[0])
ev, err := sdkutil.ParseEvent(sev)
require.NoError(t, err)
return ev
}
func ParseDeploymentEvent(t testing.TB, events []abci.Event) sdkutil.ModuleEvent {
t.Helper()
uev := ParseEvent(t, events)
iev, err := dtypes.ParseEvent(uev)
require.NoError(t, err)
return iev
}
func ParseMarketEvent(t testing.TB, events []abci.Event) sdkutil.ModuleEvent {
t.Helper()
uev := ParseEvent(t, events)
iev, err := mtypes.ParseEvent(uev)
require.NoError(t, err)
return iev
}
func ParseProviderEvent(t testing.TB, events []abci.Event) sdkutil.ModuleEvent {
t.Helper()
uev := ParseEvent(t, events)
iev, err := ptypes.ParseEvent(uev)
require.NoError(t, err)
return iev
}