-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_events.go
More file actions
249 lines (229 loc) · 7.8 KB
/
test_events.go
File metadata and controls
249 lines (229 loc) · 7.8 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
package test_main
import (
"encoding/json"
"github.com/bjartek/overflow/overflow"
"gotest.tools/assert"
)
////////////////////////////
// Action Executed Events //
////////////////////////////
// Transfer Fungible Tokens To Account
var TRANSFER_FUNGIBLE_TOKENS_EXECUTE_ACTION_EVENT, _ = json.Marshal(
map[string]interface{}{
"actionUUID": 138,
"actionView": map[string]interface{}{
"intent": "Transfer 100.00000000 A.0ae53cb6e3f42a79.FlowToken.Vault tokens from the treasury to 0x01cf0e2f2f715450",
"proposer": "0xec4809cd812aee0a",
"recipient": "0x01cf0e2f2f715450",
"timestamp": "",
"tokenAmount": 100.0,
"type": "TransferToken",
"vaultId": "A.0ae53cb6e3f42a79.FlowToken.Vault",
},
"executor": "0xec4809cd812aee0a",
"signerResponses": map[string]interface{}{
"0x06909bc5ba14c266": 0,
"0x179b6b1cb6755e31": 0,
"0x1beecc6fef95b62e": 0,
"0xec4809cd812aee0a": 0,
"0xf4a3472b32eac8d8": 0,
},
"treasuryUUID": 130,
},
)
// Transfer Fungible Tokens To Treasury
var TRANSFER_FUNGIBLE_TOKENS_TO_TREASURY_EXECUTE_ACTION_EVENT, _ = json.Marshal(
map[string]interface{}{
"actionUUID": 142,
"actionView": map[string]interface{}{
"intent": "Transfer 100.00000000 A.0ae53cb6e3f42a79.FlowToken.Vault tokens from the treasury to 0x01cf0e2f2f715450",
"proposer": "0xec4809cd812aee0a",
"timestamp": "",
"recipient": "0x01cf0e2f2f715450",
"tokenAmount": 100.0,
"type": "TransferTokenToTreasury",
"vaultId": "A.0ae53cb6e3f42a79.FlowToken.Vault",
},
"executor": "0xec4809cd812aee0a",
"signerResponses": map[string]interface{}{
"0x06909bc5ba14c266": 0,
"0x179b6b1cb6755e31": 0,
"0x1beecc6fef95b62e": 0,
"0xec4809cd812aee0a": 0,
"0xf4a3472b32eac8d8": 0,
},
"treasuryUUID": 128,
},
)
// Transfer Non Fungible Tokens To Account
var TRANSFER_NON_FUNGIBLE_TOKENS_EXECUTE_ACTION_EVENT, _ = json.Marshal(
map[string]interface{}{
"actionUUID": 135,
"actionView": map[string]interface{}{
"collectionId": "A.f8d6e0586b0a20c7.ExampleNFT.Collection",
"intent": "Transfer A.f8d6e0586b0a20c7.ExampleNFT.Collection NFT from the treasury to 0xf8d6e0586b0a20c7",
"nftId": 0,
"proposer": "0xec4809cd812aee0a",
"timestamp": "",
"recipient": "0xf8d6e0586b0a20c7",
"type": "TransferNFT",
},
"executor": "0xec4809cd812aee0a",
"signerResponses": map[string]interface{}{
"0x06909bc5ba14c266": 0,
"0x179b6b1cb6755e31": 0,
"0x1beecc6fef95b62e": 0,
"0xec4809cd812aee0a": 0,
"0xf4a3472b32eac8d8": 0,
},
"treasuryUUID": 128,
},
)
// Transfer Non Fungible Tokens To Treasury
var TRANSFER_NON_FUNGIBLE_TOKENS_TO_TREASURY_EXECUTE_ACTION_EVENT, _ = json.Marshal(
map[string]interface{}{
"actionUUID": 139,
"actionView": map[string]interface{}{
"collectionId": "A.f8d6e0586b0a20c7.ExampleNFT.Collection",
"intent": "Transfer an NFT from collection A.f8d6e0586b0a20c7.ExampleNFT.Collection with ID 0 from this Treasury to Treasury at address 0x01cf0e2f2f715450",
"nftId": 0,
"proposer": "0xec4809cd812aee0a",
"timestamp": "",
"recipient": "0x01cf0e2f2f715450",
"type": "TransferNFTToTreasury",
},
"executor": "0xec4809cd812aee0a",
"signerResponses": map[string]interface{}{
"0x06909bc5ba14c266": 0,
"0x179b6b1cb6755e31": 0,
"0x1beecc6fef95b62e": 0,
"0xec4809cd812aee0a": 0,
"0xf4a3472b32eac8d8": 0,
},
"treasuryUUID": 126,
},
)
// Update Threshold
var UPDATE_THRESHOLD_EXECUTE_ACTION_EVENT, _ = json.Marshal(
map[string]interface{}{
"actionUUID": 131,
"actionView": map[string]interface{}{
"intent": "Update the threshold of signers to 5.",
"newThreshold": 5,
"proposer": "0xec4809cd812aee0a",
"timestamp": "",
"type": "UpdateThreshold",
},
"executor": "0xec4809cd812aee0a",
"signerResponses": map[string]interface{}{
"0x06909bc5ba14c266": 0,
"0x179b6b1cb6755e31": 0,
"0x1beecc6fef95b62e": 0,
"0xec4809cd812aee0a": 0,
"0xf4a3472b32eac8d8": 0,
},
"treasuryUUID": 126,
},
)
// Add Signer Update Threshold
var ADD_SIGNER_UPDATE_THRESHOLD_EXECUTE_ACTION_EVENT, _ = json.Marshal(
map[string]interface{}{
"actionUUID": 131,
"actionView": map[string]interface{}{
"intent": "Add signer 0x1beecc6fef95b62e. Update the threshold of signers to 5.",
"newThreshold": 5,
"proposer": "0xec4809cd812aee0a",
"timestamp": "",
"signerAddr": "0x1beecc6fef95b62e",
"type": "AddSignerUpdateThreshold",
},
"executor": "0xec4809cd812aee0a",
"signerResponses": map[string]interface{}{
"0x06909bc5ba14c266": 0,
"0x179b6b1cb6755e31": 0,
"0xec4809cd812aee0a": 0,
"0xf4a3472b32eac8d8": 0,
},
"treasuryUUID": 126,
},
)
// Remove Signer Update Threshold
var REMOVE_SIGNER_UPDATE_THRESHOLD_EXECUTE_ACTION_EVENT, _ = json.Marshal(
map[string]interface{}{
"actionUUID": 131,
"actionView": map[string]interface{}{
"intent": "Remove signer 0x1beecc6fef95b62e. Update the threshold of signers to 4.",
"newThreshold": 4,
"proposer": "0xec4809cd812aee0a",
"timestamp": "",
"signerAddr": "0x1beecc6fef95b62e",
"type": "RemoveSignerUpdateThreshold",
},
"executor": "0xec4809cd812aee0a",
"signerResponses": map[string]interface{}{
"0x06909bc5ba14c266": 0,
"0x179b6b1cb6755e31": 0,
"0x1beecc6fef95b62e": 0,
"0xec4809cd812aee0a": 0,
"0xf4a3472b32eac8d8": 0,
},
"treasuryUUID": 126,
},
)
///////////////////////////////////////////
// Signer Approve/Reject Action Events //
///////////////////////////////////////////
// Signer Approve Action
var ACTION_APPROVED_BY_SIGNER_EVENT, _ = json.Marshal(
map[string]interface{}{
"actionUUID": 138,
"address": "0x1beecc6fef95b62e",
"signerResponses": map[string]interface{}{
"0x06909bc5ba14c266": 0,
"0x179b6b1cb6755e31": 0,
"0x1beecc6fef95b62e": 0,
"0xec4809cd812aee0a": 0,
"0xf4a3472b32eac8d8": 0,
},
"treasuryUUID": 130,
},
)
// Signer Reject Action
var ACTION_REJECTED_BY_SIGNER_EVENT, _ = json.Marshal(
map[string]interface{}{
"actionUUID": 134,
"address": "0x1beecc6fef95b62e",
"signerResponses": map[string]interface{}{
"0x06909bc5ba14c266": 1,
"0x179b6b1cb6755e31": 1,
"0x1beecc6fef95b62e": 1,
"0xec4809cd812aee0a": 1,
"0xf4a3472b32eac8d8": 1,
},
"treasuryUUID": 128,
},
)
//////////////////////////
// Test Event Functions //
//////////////////////////
func (otu *OverflowTestUtils) AssertActionExecutedEventsMatch(txResult overflow.TransactionResult, expected []byte) {
txResult.AssertEmitEventName("A.f8d6e0586b0a20c7.DAOTreasuryV5.ActionExecuted")
event := txResult.Result.GetEventsWithName("A.f8d6e0586b0a20c7.DAOTreasuryV5.ActionExecuted")[0]
// timestamp is a dynamic field in an ActionView interface, it's very hard to test it
// Here we are resetting the value to an empty string to match an empty timestamp from expected payloads
event["actionView"].(map[string]interface{})["timestamp"] = ""
fieldsJson, _ := json.Marshal(event)
assert.Equal(otu.T, string(expected), string(fieldsJson))
}
func (otu *OverflowTestUtils) AssertActionApprovedBySignerEvent(txResult overflow.TransactionResult, expected []byte) {
txResult.AssertEmitEventName("A.f8d6e0586b0a20c7.DAOTreasuryV5.ActionApprovedBySigner")
event := txResult.Result.GetEventsWithName("A.f8d6e0586b0a20c7.DAOTreasuryV5.ActionApprovedBySigner")[0]
fieldsJson, _ := json.Marshal(event)
assert.Equal(otu.T, string(expected), string(fieldsJson))
}
func (otu *OverflowTestUtils) AssertActionRejectedBySignerEvent(txResult overflow.TransactionResult, expected []byte) {
txResult.AssertEmitEventName("A.f8d6e0586b0a20c7.DAOTreasuryV5.ActionRejectedBySigner")
event := txResult.Result.GetEventsWithName("A.f8d6e0586b0a20c7.DAOTreasuryV5.ActionRejectedBySigner")[0]
fieldsJson, _ := json.Marshal(event)
assert.Equal(otu.T, string(expected), string(fieldsJson))
}