-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
bmap_test.go
461 lines (395 loc) · 51.1 KB
/
bmap_test.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
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
package bmap
import (
"testing"
"github.com/bitcoin-sv/go-sdk/transaction"
"github.com/bitcoinschema/go-b"
"github.com/bitcoinschema/go-bap"
"github.com/bitcoinschema/go-bmap/run"
"github.com/bitcoinschema/go-bmap/test"
"github.com/bitcoinschema/go-bob"
"github.com/bitcoinschema/go-bpu"
magic "github.com/bitcoinschema/go-map"
)
var cryptoFights = "cryptofights"
var something = "something"
var tpowStr = "tonicpow"
func TestFromBob(t *testing.T) {
dataSource := `{"_id":"5ebc04c7814c6a17a6c90b3b","tx":{"h":"ce7429a101b7aecdf1e5449151d0be17a3948cb5c22282832ae942107edb2272"},"in":[{"i":0,"tape":[{"cell":[{"b":"MEQCIDUGRtDdmf2I2p1vcA2s4fMuBcmnSi5kOI2chSiFrYQKAiAq8XSIx8EbM2oKJJC9t/SFXTGnJBfE7mRKdGOVR7zIB0E=","s":"0D\u0002 5\u0006F�ݙ��ڝop\r���.\u0005ɧJ.d8���(���\n\u0002 *�t���\u001b3j\n$����]1�$\u0017��dJtc�G��\u0007A","ii":0,"i":0},{"b":"A/20DJgUWAXROgZTKDRmcC0ja306xpg3SiMTPy3QKhqQ","s":"\u0003��\f�\u0014X\u0005�:\u0006S(4fp-#k}:Ƙ7J#\u0013?-�*\u001a�","ii":1,"i":1}],"i":0}],"e":{"h":"f8448e73fc7667b91f86cf152b9bc4d88c365174989d79871e64ca8c66c1e785","i":0,"a":"1P1dKk7BCB6iTUz13w1eXkLfcj8a8dC4iv"},"seq":4294967295}],"out":[{"i":0,"tape":[{"cell":[{"op":0,"ops":"OP_0","ii":0,"i":0},{"op":106,"ops":"OP_RETURN","ii":1,"i":1}],"i":0},{"cell":[{"b":"MVB1UWE3SzYyTWlLQ3Rzc1NMS3kxa2g1NldXVTdNdFVSNQ==","s":"1PuQa7K62MiKCtssSLKy1kh56WWU7MtUR5","ii":2,"i":0},{"b":"U0VU","s":"SET","ii":3,"i":1},{"b":"YXBw","s":"app","ii":4,"i":2},{"b":"MnBheW1haWw=","s":"2paymail","ii":5,"i":3},{"b":"cGF5bWFpbA==","s":"paymail","ii":6,"i":4},{"b":"aGFnYmFyZEBtb25leWJ1dHRvbi5jb20=","s":"[email protected]","ii":7,"i":5},{"b":"cHVibGljX2tleQ==","s":"public_key","ii":8,"i":6},{"b":"MDJjODliNjc5MGViNjA1MDYyYTMxZjEyNDI1MDU5NGJkMGZkMDI5ODhkYTI1NDFiM2QyNWU3ZWYzOTM3ZmI0YWUw","s":"02c89b6790eb605062a31f124250594bd0fd02988da2541b3d25e7ef3937fb4ae0","ii":9,"i":7},{"b":"cGxhdGZvcm0=","s":"platform","ii":10,"i":8},{"b":"dHdpdHRlcg==","s":"twitter","ii":11,"i":9},{"b":"cHJvb2ZfdXJs","s":"proof_url","ii":12,"i":10},{"b":"aHR0cHM6Ly90d2l0dGVyLmNvbS9oYWdiYXJkZGQvc3RhdHVzLzEyMDUxODk1ODAzMDkzNzcwMjQ=","s":"https://twitter.com/hagbarddd/status/1205189580309377024","ii":13,"i":11},{"b":"cHJvb2ZfYm9keQ==","s":"proof_body","ii":14,"i":12},{"b":"SGkKCk15IHBheW1haWwgaXMgaGFnYmFyZEBtb25leWJ1dHRvbi5jb20=","s":"Hi\n\nMy paymail is [email protected]","ii":15,"i":13},{"b":"cHJvb2ZfaWQ=","s":"proof_id","ii":16,"i":14},{"b":"Sms5dlFncGREcG9XMHFEWQ==","s":"Jk9vQgpdDpoW0qDY","ii":17,"i":15}],"i":1},{"cell":[{"b":"MXNpZ255Q2l6cDFWeUJzSjVTczJ0RUFndzd6Q1lOSnU0","s":"1signyCizp1VyBsJ5Ss2tEAgw7zCYNJu4","ii":19,"i":0},{"b":"SU5LRmIxNU1uQVhxTlFueStiNEtBVm5HTnR5bUcwZEhTdTEzKzg3MSt0aTBXTjVGQmVBLzdEZ1VuMXRsdzZGN29kYlc3SURyVmVQS1RMclRQQWlEcXlvPQ==","s":"INKFb15MnAXqNQny+b4KAVnGNtymG0dHSu13+871+ti0WN5FBeA/7DgUn1tlw6F7odbW7IDrVePKTLrTPAiDqyo=","ii":20,"i":1},{"b":"MDJjODliNjc5MGViNjA1MDYyYTMxZjEyNDI1MDU5NGJkMGZkMDI5ODhkYTI1NDFiM2QyNWU3ZWYzOTM3ZmI0YWUw","s":"02c89b6790eb605062a31f124250594bd0fd02988da2541b3d25e7ef3937fb4ae0","ii":21,"i":2},{"b":"aGFnYmFyZEBtb25leWJ1dHRvbi5jb20=","s":"[email protected]","ii":22,"i":3}],"i":2}],"e":{"v":0,"i":0,"a":"false"}},{"i":1,"tape":[{"cell":[{"op":118,"ops":"OP_DUP","ii":0,"i":0},{"op":169,"ops":"OP_HASH160","ii":1,"i":1},{"b":"7njcAgMt9eekcx5JZXFDoaThy9M=","s":"�x�\u0002\u0003-��s\u001eIeqC�����","ii":2,"i":2},{"op":136,"ops":"OP_EQUALVERIFY","ii":3,"i":3},{"op":172,"ops":"OP_CHECKSIG","ii":4,"i":4}],"i":0}],"e":{"v":31202,"i":1,"a":"1Njvc7dj8UHG6hnV5k5ZjSJtPgTofknDmx"}}],"lock":0,"blk":{"i":618112,"h":"000000000000000001e1e1f2995c9ba2e316f6fb85c247c923c591e56ea00fb6","t":1579328162},"i":478}`
bobData, err := bob.NewFromString(dataSource)
if err != nil {
t.Fatalf("failed to create bob tx %s", err)
}
var bmapData *Tx
if bmapData, err = NewFromBob(bobData); err != nil {
t.Fatalf("error occurred: %s", err)
}
if bmapData.Tx.Tx.H != "ce7429a101b7aecdf1e5449151d0be17a3948cb5c22282832ae942107edb2272" {
t.Fatalf("inherited field failed %+v", bmapData.MAP)
}
mapData := bmapData.MAP
if mapData[0]["app"] != "2paymail" {
t.Fatalf("test fromBob failed %+v", mapData)
}
}
func TestFromTx(t *testing.T) {
t.Run("error", func(t *testing.T) {
tx := ""
_, err := NewFromRawTxString(tx)
if err == nil {
t.Fatalf("error should occur")
}
})
t.Run("success", func(t *testing.T) {
tx := "01000000018952fe8892c429e69feb9b2dd9cd1f12ed757dc62e8d628b5a215f78ed895374020000006a47304402204784632fabca0f4aaa05dd6983633b2e8bf708d8766d0385f3393fff0623b88c02201a760e144116d47967501c2ea50dc231ae57c0eb78769d63713ce0648025c820412103221cb24c4e8b05a58bcf2ee8411f62e337c8099c8646babd47d0960899f69acaffffffff04680b0000000000001976a91409cc4559bdcb84cb35c107743f0dbb10d66679cc88ac0f720000000000001976a9146b1fe7b2063aa07766c764c0796fd4efd00340f288ac8a893b00000000001976a914be5f62df829ef754b8be09b37b04c4e7f9ff59d588ac0000000000000000ad006a223150755161374b36324d694b43747373534c4b79316b683536575755374d74555235035345540361707008746f6e6963706f7704747970650b6f666665725f636c69636b0f6f666665725f636f6e6669675f696403383038106f666665725f73657373696f6e5f6964403464303537386561643432393266653163643163393936643931623534613130653333653334623031396231386330613564353730376461346461346437653900000000"
bmapData, err := NewFromRawTxString(tx)
if err != nil {
t.Fatalf("error occurred: %s", err)
}
if bmapData.Tx.Tx.H != "1817ecc5b3207d9b33014b461688477146139105f198d69efadc73d05cfd3ed8" {
t.Fatalf("inherited field failed %+v", bmapData.MAP)
}
mapData := bmapData.MAP
if mapData[0]["app"] != tpowStr {
t.Fatalf("test fromTx failed %+v", mapData)
}
})
t.Run("run + non standard", func(t *testing.T) {
tx := "01000000023df0e0c5933a28f8a60572588aa2073ebe6297b48e3196e2c404a6869e45eb0d020000006b483045022100e349bcbf4002426a472daf2c02921c7a98d01f5462ae66eaf2bac0973a37033a02203c35870bcf7febbbe5e75a90a86918153eea8b8976f5546871b50c7674c9c1154121024ee11d705c041678b7fe9b34490c099fb7ae915e4267ecbe290874f0fc1863b3ffffffff4e32d8d868b6fd280b7af6a70e008f0c05f769b5263ff81c63092ec32a8ba159040000006a47304402203f8236b23b50f758dad4522acb793f73305aa1efda1ab7b305facf09665eae91022049366bad7e887aecd45f2cdafec4a3b21c3f880431fe142809450981881fcf7b41210361e9371c81d97f869d51e6909eb1132fc6c55b2caa8c4cea6d06a4f99b446decffffffff0422020000000000001976a9145a468879d2c7f3d48e6664a76286c96653a8ed4488ac0000000000000000fd9d03006a0372756e01050972656c6179782e696f4d88037b22696e223a312c22726566223a5b22643631373030323561363232343864386466366463313465333830366536386238646633643830346338303063376266623233623062343233323836323530355f6f31222c22656162396666366464316165383230363535343635356537653130613766323161613039653232613462386634643034386661353431633137393764633735655f6f31222c22373261363165623939306666646236623338653566393535653139346665643566663662303134663735616336383233353339636535363133616561306265385f6f31222c22373237653762343233623765653430633062356265383766626137666135363733656132643230613734323539303430613732393564396333326139303031315f6f31222c22383162636566323962306534656437343566333432326330623736346133336337366430333638616632643265376464313339646238653030656533643861365f6f31222c22343931343536393336373661663735363765626532303637316335636230313336396163373838633230663362316338303466363234613165646131386633665f6f31222c22336237656634313131383562626533643031636165616462653666313135623031303361353436633465663061633734373461613666626237316166663230385f6f31225d2c226f7574223a5b2230323164363634333831613532306434636439383732373638333866356339336661353763393835626631356134633739656537633932643931396437373263225d2c2264656c223a5b2237306163303437613037383638643562636538333130633530383637623631313639373534346134386165353161353931356339643163636536303766383236225d2c22637265223a5b7b2224617262223a7b2261646472657373223a2231424b4475665758434b6672714b6e75465664524668554d4a4733654c6b77483767222c227361746f73686973223a31343030303030307d2c2254223a7b22246a6967223a317d7d5d2c2265786563223a5b7b226f70223a2243414c4c222c2264617461223a5b7b22246a6967223a307d2c2273656e64222c5b7b2224617262223a7b2261646472657373223a2231424b4475665758434b6672714b6e75465664524668554d4a4733654c6b77483767222c227361746f73686973223a31343030303030307d2c2254223a7b22246a6967223a317d7d2c355d5d7d5d7d8705000000000000fd100320b88bf03d21d88541df8c758a1da474c783f7c362c9daf2670229d9d55ef8226a01c35279630142517a75547901687f7501447f77007901207f7504000000007e517951797e56797eaa577901247f75547f77876975756754795579827758947f75557982770128947f77527987696861547921cdb285cc49e5ff3eed6536e7b426e8a528b05bf9276bd05431a671743e651ceb002102dca1e194dd541a47f4c85fea6a4d45bb50f16ed2fddc391bf80b525454f8b40920f941a26b1c1802eaa09109701e4e632e1ef730b0b68c9517e7c19be2ba4c7d37202f282d163597a82d72c263b004695297aecb4d758dccd1dbf61e82a3360bde2c202cde0b36a3821ef6dbd1cc8d754dcbae97526904b063c2722da89735162d282f56795679aa616100790079517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01007e81517a756157795679567956795679537956795479577995939521414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff0061517951795179517997527a75517a5179009f635179517993527a75517a685179517a75517a7561527a75517a517951795296a0630079527994527a75517a68537982775279827754527993517993013051797e527e53797e57797e527e52797e5579517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7e56797e0079517a75517a75517a75517a75517a75517a75517a75517a75517a75517a75517a75517a756100795779ac517a75517a75517a75517a75517a75517a75517a75517a75517a7561777777777738a20100000000001976a914f4993778efa9207d8f2670348c197dffdfe4f32f88ac00000000"
bmapData, err := NewFromRawTxString(tx)
if err != nil {
t.Fatalf("error occurred: %s", err)
}
if bmapData.Tx.Tx.H != "a7ccc556170fbafb219990b031839197837fc2bd912928afcc513e0dbf62b54f" {
t.Fatalf("bmap tx id incorrect %+v", bmapData)
}
runData := bmapData.Run
if runData[0].Payload.Out[0] != "021d664381a520d4cd987276838f5c93fa57c985bf15a4c79ee7c92d919d772c" {
t.Fatalf("failed parsing run data %+v", runData)
}
})
}
func TestMap(t *testing.T) {
keyName1 := "keyName1"
keyName2 := something
somethingElse := "something else"
tape := bpu.Tape{
Cell: []bpu.Cell{
{S: &magic.Prefix},
{S: &magic.Set},
{S: &keyName1},
{S: &something},
{S: &keyName2},
{S: &somethingElse},
},
}
m, err := magic.NewFromTape(&tape)
if err != nil {
t.Fatalf("error occurred: %s", err)
} else if m["keyName1"] != something {
t.Fatalf("SET Failed %s", m["keyName1"])
}
}
func TestMapFromRawTxString(t *testing.T) {
bTx, err := bob.NewFromRawTxString(`01000000018952fe8892c429e69feb9b2dd9cd1f12ed757dc62e8d628b5a215f78ed895374020000006a47304402204784632fabca0f4aaa05dd6983633b2e8bf708d8766d0385f3393fff0623b88c02201a760e144116d47967501c2ea50dc231ae57c0eb78769d63713ce0648025c820412103221cb24c4e8b05a58bcf2ee8411f62e337c8099c8646babd47d0960899f69acaffffffff04680b0000000000001976a91409cc4559bdcb84cb35c107743f0dbb10d66679cc88ac0f720000000000001976a9146b1fe7b2063aa07766c764c0796fd4efd00340f288ac8a893b00000000001976a914be5f62df829ef754b8be09b37b04c4e7f9ff59d588ac0000000000000000ad006a223150755161374b36324d694b43747373534c4b79316b683536575755374d74555235035345540361707008746f6e6963706f7704747970650b6f666665725f636c69636b0f6f666665725f636f6e6669675f696403383038106f666665725f73657373696f6e5f6964403464303537386561643432393266653163643163393936643931623534613130653333653334623031396231386330613564353730376461346461346437653900000000`)
if err != nil {
t.Fatalf("error occurred: %s", err)
}
var m magic.MAP
m, err = magic.NewFromTape(&bTx.Out[3].Tape[1])
if err != nil {
t.Fatalf("error occurred: %s", err)
} else if m["CMD"] != "SET" && m["app"] != tpowStr {
t.Fatalf("SET Failed %v", m)
}
}
func TestMapFromTx(t *testing.T) {
tx, err := transaction.NewTransactionFromHex(`01000000018952fe8892c429e69feb9b2dd9cd1f12ed757dc62e8d628b5a215f78ed895374020000006a47304402204784632fabca0f4aaa05dd6983633b2e8bf708d8766d0385f3393fff0623b88c02201a760e144116d47967501c2ea50dc231ae57c0eb78769d63713ce0648025c820412103221cb24c4e8b05a58bcf2ee8411f62e337c8099c8646babd47d0960899f69acaffffffff04680b0000000000001976a91409cc4559bdcb84cb35c107743f0dbb10d66679cc88ac0f720000000000001976a9146b1fe7b2063aa07766c764c0796fd4efd00340f288ac8a893b00000000001976a914be5f62df829ef754b8be09b37b04c4e7f9ff59d588ac0000000000000000ad006a223150755161374b36324d694b43747373534c4b79316b683536575755374d74555235035345540361707008746f6e6963706f7704747970650b6f666665725f636c69636b0f6f666665725f636f6e6669675f696403383038106f666665725f73657373696f6e5f6964403464303537386561643432393266653163643163393936643931623534613130653333653334623031396231386330613564353730376461346461346437653900000000`)
if err != nil {
t.Fatalf("error occurred: %s", err)
}
bmapTx, err := NewFromTx(tx)
if err != nil {
t.Fatalf("error occurred: %s", err)
} else if bmapTx.MAP[0]["CMD"] != "SET" && bmapTx.MAP[0]["app"] != tpowStr {
t.Fatalf("SET Failed %v", bmapTx)
}
}
func TestOrdFromTx(t *testing.T) {
tx, err := transaction.NewTransactionFromHex(`0100000001aa109509231612d4e06c8f16acf2ca81f57f1b14be1f97ce752c609d090ab900000000006b483045022100d55bf697f1701132a225d04e5b73108b924aef0d0c06a9e0808660664989a908022017df9e83dc5dff9b5416ca1cc8be813ed76f93a9fb45b97b3c483ce24cee720d412102da552fe9c6500a9052742ad7d8a20177616ed8cff7bcc29e29e64e05928f9d19ffffffff020100000000000000fd961576a914bae45dcceef412ff67c27f3cde2520edf16c6cd588ac0063036f7264510a696d6167652f6a706567004d661589504e470d0a1a0a0000000d4948445200000258000002580806000000be6698dc00000184694343504943432070726f66696c65000028917d913d48c3401cc55f53a5a2950eed20e290a13a59101571942a16c142692bb4ea6072e917346948525c1c05d782831f8b550717675d1d5c0541f003c4d5c549d1454afc5f526811e3c1713fdedd7bdcbd03846695a966cf04a06a96914ec4c55c7e550cbcc28f300620202431534f6616b3f01c5ff7f0f1f52ec6b3bccffd39069582c9009f483cc774c322de209ed9b474cefbc411569614e273e271832e48fcc875d9e537ce2587059e1931b2e979e208b158ea62b98b59d95089a789a38aaa51be907359e1bcc559add659fb9efc85c182b692e13acd1124b08424521021a38e0aaab010a35523c5449af6e31efe61c79f22974cae0a18391650830ac9f183ffc1ef6ecde2d4a49b148c03bd2fb6fd310a04768156c3b6bf8f6dbb7502f89f812bade3af3581d94fd21b1d2d7a0484b6818beb8e26ef01973bc0d0932e199223f9690ac522f07e46df9407c2b740ff9adb5b7b1fa70f4096ba5abe010e0e81b11265af7bbcbbafbbb77fcfb4fbfb010ee9727f2117c72a00000006624b474400ff0000000033277cf3000000097048597300000b1300000b1301009a9c180000000774494d4507e703130b021b769f47b4000013634944415478daedddbf8f1c671dc0e1f7dd3b07e35841a2a00205e270891409910225168a04455a6a64628a14984434e9f227f0079c026ec20f2714943414290005c9b28214290291843804d1512083d1e522e76628eef67cbb37733bb333b3f3ceccf34891edbbf53af77ad7f7d9efce3b13b3eb210f0000b4666609000004160080c0020010580000082c000081050020b0000010580000020b004060010020b0000004160080c0020010580000082c000081050020b0000010580000020b004060010020b0000004160080c0020040600100082c000081050020b0000010580000020b004060010020b0000004160080c0020040600100082c0080a1dab60490d02b9e6bd680fbb2ebd60006fbefb925000010580000020b004060010020b0000004160080c0020040600100082c000081050080c00200e856ccae87dc324033175fbad0e9fdefeded59645672ed42488709160080c0020010580000020b000081050020b0000004160000020b0040600100082c000004160040c7b62d01c0485e315fab777bd72e840e9f8f96000040600100082c008029710c164c588c71d25f7f9ee71e0440274cb000005a668205052ebe7461525fefce87cff7f2e7beffc8ab1e6c7dbec2bed6cefdd88d08020be0d8596f917afb1068f402c6120000b4cb040ba0c0f274cb440ba8c3040b00a06526580015941daf65b205082c48ccc71f7fdce89b7b99be7605d665f72220b000582b7e4db9406001d090a00204164cd8542f9533ffbabb0aa1a275155d20b0808998ea377db103082ca033265879726b2dfe6024ffce64d7836733a397eab505abee222cd37417de5403abaf98a9b27b71ca81e59a868c890916404aaf7a9d411e46c199dc01005a66820590b075dec635f582fe99600100b4cc040b98ac3ad3a1214d85ec5804810593f4c53f7f378410c26c66883c2575777dba6622082c80515b3515320d02041640870126b6008105d0616c892e982607800000b4cc040b6003ca8ee132d982913ee75d8b90214aedda82f35d8175d945489b815577d7e1d0e3ceb50b49990916409faf724db66094bc7c06006899091640824cb6406001d04378892d10580074185b277f2dbc4060c1a0cd7701da0d480ae6d73aac1a581f3dfa8b53b79fffbce83e569d4035afb0293d86fbf79135fe8a8524020b800d590e21132d105800bd85c858a364d585aa9bdeb78083d3bcaf01c066422f448b80c002605ace9a44753905038105006511664205f79f0fae45480a867a6d41bb0707fe0f600b5399211f7f347ffc2eef1cbcfd95574f7d5dabd6eaf83ecef896b21c604d77116635bf7db976211b7d7e590280e9ea2b10bde5c8d8d9450820ae6ac5d05967938f21164eb1bc7d88c0026072a71e283ad9681d4ed700020ba0523008b2d5eb5214566553ac75d7160416c04899ceac0ea3b22996b7071158004c3a1ef33c0f97fefe7c61547df8c8cf2a87555954995e21b000440725e6a1345fa7796439160b0416c0ca80187b88ad7b40fbc99f0b2a1058001b0b91a17d4d552e95735678ae9a62797b902971a251001a114e709a0916305953796babeceb3ceb84a1eb44d6c9fb28fa35082c1899aad716645aea7cd31f728cb51537656f139685556a5135bb56eff6ae5d88c00268d9d4a75b1b893e07c733628ec1021091ab63a8c2e7ab1c085fe5f33006265880c0f07555268ea01a132c809189312efcd7e59fb11c5eaba658028da930c10218994d4ee69c681404161b74f1a50b160146a4685ad5e43e86a0eeae43fa95daae4f810530506d4e8e8a4ead503588cacee0be7cbd429812810530505d5c2f711e4acb3f5f27b8eafe3e10580024abeec4a8ca99de817aec220410638d89315864820530d138726c14082c12d5d76e41d71684fe39450394f316210040cb4cb018ec2be794ee0786f83ca8b30b31cff3b0757cf37cfe89b0700f3184707c9fb1d29f3f9f809d9c841d988a21b000a059e09d756a88e5d00381050067ca8e065e8b71b5b51455d952909df8a42524598ec102a017cbc15434b9f2363e4365820540cfa1951fbdfd373b155487c77ec5855fcf1d583a12668205408f7115177eac7a7b10580050f80d2886b870185576f49fc8426001c0c6892c041600d4526d92052973903b00bd9a9f70f4f454caf9b01058d0c8137f7da2e6ef78a7d6adff9b7dcd2243aa81958710430c59580ea72c1c9e357e762ac82075de220420ddf81253082c00583fa0ca622ac63c38260b8105002d0457958f83c0028046916592c57038c81d8064236b79c7e0e1c7ab9ffddd8e430416009d7868f64e2bf7f3c4ed270b3ffe974b6fb71253b1f893a5bfefe0a7e28974798b100040600100082c000081050080c0020048865d84542bf16b659fd9b3380020b0e03ee7c89936670707bae22d42000081050020b0000004160000eb73903b74e80f7ffad022d0ba6f7de3924580c499600100082c000081050030298ec122099fe6e73bbdff0bf1fdc28fefe53b161f80d699600100b4cc048b24fcf6adbe1e8a76f9313cbf7feb76addb7fe7296b069b6682050020b0000004160080c002004060010024c32e428091fbcdad075bb99f4b57fe6831a122132c000081050020b0000004160000020b0040600100082c000004160080c0020010580000082c000081050020b0000004160000020b0040600100082c0000d6b26d090048d9dddd7b1681c131c1020010580000020b004060010020b0000092611721bdfadc039f3dfc4996f7f2e7e7d1df012d3fa6f27c325f6bb6d5ec09343bc83d60182d132c000081050020b0000004160000020b00201976119284c7aedeb2081bf0ee6b4f0de2ff7367438f8759079bd8c6bd8b70f935b95d8050f5d9020080c0020010580000020b0000810500d01bbb080148c2dddd7b1681d130c1020010580000020b0060521c834567628cc73fceff3bf9716058b6c2e2733766cd9ecbb933c13362265800002d33c1a253cbd32a532c00a6c0048bcec34a4c0120b0a0a3c832bd02602abc4548a76155f6b9e3db38c615801132c1a2f3d83a39bd5a15600030062658b41e54651155f836a109160023648245eb71b51c54653b090160ac4cb0e83cb48a624b6401306626587412554593abb3020c00c6c4048b8d8456f904cb4158008c8f0916bd471800082c6829a084160063e52d42928aaea62e3cf9e341afd3dedb2f7bb0b4e8e2d737ff78c8f3dcdf3b608245b74155b673d0f40a803133c162a98c8a7fbd3d3b77f4816ce1d307d9c1fc657b88211efe388b21cee32a3fbc8b78f2aef3c30f8a2ce85bd6ec157ac33d2a07c1bf018c9709160080c02265a6520020b0682bac42f1059dcb826b9d03810160281c8345bba1557206f7a28f892c76aedeb20880c082c2a80aa72feaecad42000416b41057656f0b8a2d000416ac1b5b2bce7d050053e120771a4755d971570030552658b4165845132c0010584cde033f78e8a89c3e3dfac8d1999ee341e5c05afebcdd82e978fcb9c55d7b990e06e884b70869a4ca04abec140dc20b008105258155f66b6f130220b0a04164d5092b932b000416d408ade59f3b5d0300020b1a44959002804376110e3d70da7ab72dde0fa418630871b6184d71e986f342df3a7ccbefb0abf293a575f8ebe51fc389dbc5a8f1011825dfdd00005a6682c5a2981d4d96e6e7bfca8f8656d9fdcf2fd8b26600b0c4040b00a06526581c2a3d363d3bfce4f1e4ca040b005631c1020068990916c54ab7273a492800ac62820500d032132c961c1d7375ead799a501808a4cb000005a6682453dd1315800b08a09160040cb4cb026eac11f7e6ee1d771be3b707670f8633e3f0eeb5c383c06ebe8a1b23cc09adf9e4178f7b5a77af97377aedeb2f8c0a498600100082c000081050030298ec11ab83caef7fbee9ddb0b218410e3e21d14de5d2cff4366f951a32f1f9b958710433cfde3d26df0381d9b18ab7fb179ee49006365820500d032132c3ab1bfbf5ff8f1f3e7cf5b9c09fadb2febed5efceaf7ed3a0486cd040b0040600100082c000081050080c0020048865d8423f7991f9db30813d4d73507db52b6eb30b5dd857b6fbfdce8f73b0f168c9709160080c0020010580000020b0000810500908c985d0fb6b18cd8aa5d8431c6d50f92336e732e366bf4adccdf511543df15d89755bb0efb7efcf5bf8bb0df0538088bffb6dcddfdc48396d130c102006899f360014cd4c1acd96beca6f3af59e60d14c6cb040b0040600100082c008049710c164978ef46b7bbe41ebbdacf35ececfeeb57d9350dcb3cfedc2d8b06b4c2040b0040600100082c000081050080c0020048865d8423b1ea9a83c06a6dedfaacbb1bb1afdda6abaed508accf040b0040600100082c0000810500c0fa1ce4cea4c518077dff3493e7b945000416d5be912f7f533feb9bfc769655f92e146ebff6cd7ebe01b6d427efbdfe740821846ce9fe66bebf7ade7460fe781bbb5976b0d6efbbbb7bcf838ff13f3f2c010040bb4cb00008218490d5bcbd57e8e0f90100b031265800135736b9caedd180b599600100b4cc040b800565932b132da8ce040b00a06526580084104e4fa84cac607d265800002d33c102a092cc124065265800002d33c10260c1f2b157eb4eae5c73902933c1020010580000020b004060010020b00000926117218057da218410b2bce4f3cee80e6b3faf000068890916c044c5a389d5fcbc576593ac985b2ba8cb040b00a065265800135736c902d6e7790400d032132c80917bfcb95b956e5776ac55be6217a16b0ec269265800002d33c10298ea2beca38955b66242553ad9b28450fefcb2040000ed32c10298fa2bed8a932cafd1c1b30300406001d0f33784fcfe340b105800004999fc315865871ce403f9ff9cdbcacb6f5bf47bdbbab6581ebbfdba571d13e2d5f6c09f7f79bfaff1f298f94b003a6182050020b0000004160080c0020040600100082c000081050080c002001058000023b06d09207d5fbe7a73945f5736db6ae57efef9f3a73d4880a498600100082c000081050020b0000010580000020b004060010020b0000004160080c0020040600100082c000081050020b0000010580000020b004060010020b0000004160080c00200406001006cd8b62500a62ae6cd5e63e631b3884021132c0080969960c1007c74e3b245384b6e9204a4c5040b0040600100082c000081050080c0020010580000020b000081050020b0000004160000020b0040600100082c008049dbb604c0d0e5d11a006931c1020010580000020b004060010020b0000004160080c0020040600100082c008011702677a8e11f3fb96a1138f6f00b372c0250c8040b0040600100082c000081050080c0020048865d841abbd2adf2d8d3ff5d9ef6fdc1106459661120c9efae0000082c000081050020b00000105800001b6017210b3e78fdb2450080864cb0000004160080c0020010580000082c000081050020b0000010580000020b004060010020b000003ae65a84909067df7cd1226cc01bcfbc6211804e99600100082c000081050020b0000010580000020b004060010020b0000004160080c0020040600100082c00008105003069db9600808557de79d55b468b0565cf234b000020b0000004160080c0020040600100082c000081050080c0020010580000c3e74cee9090379e79c522b0d2ce959b1601126782050020b0000004160080c002004060010024c32e4260b2aff0b289afff9ddd7d0f4218e9bf6f0000020b000081050020b0000004160000c7ec220438f2f00b372c02d00a132c000081050020b0000004160000020b0020197611b2e0d1efdd2cfcf807af5fb6380cce97aefd7ac54bcc4f2c12d009132c000081050020b0000026c53158406fb2ce5f423ac60ae88709160040cb4cb0a08667df7cb1d3fb7fe399572cf21ac67a0dc19d2bc5bb7aefeceefb4b87c499600100082c000081050020b0000010580000020b004060010020b0000004160080c002004060010074ccb5080136a4ecda82c0f898600100082c000081050020b0000010580000c9b08b10604d757705ded9ddb768301126580000020b0040600100082c00000416004032ec220406cf35fe80d498600100082c000081050020b0000010580000020b004060010020b0000004160080c002004060010074ccb5082121cfbef9a24548d09ddd7d8b00d46282050020b0000004160080c0020040600100082c000081050080c002001058000023e04cee407ff29eff098a9ffa3b003a61820500d032132c60b4fef3caffcefc7c9e5b23a01b26580000020b0040600100082c000004160080c0020010580000082c000081050020b00000105800001d732d4248c89dddfd497dbd31fa3b07c6c9040b00a065939f60e523f9ffdc8ab3e17f914ceff9e7b1098c9409160080c0020010580000020b000081050020b0000004160000020b00406001008c806b11420defffea72e1c777aedcb438001c33c1020010580000020b004060010020b0000004160080c0020040600100082c000081050080c0020010580000020b004060010020b0000004160080c00200602ddb96802abef0efdfd5bafdbf3eff6d8b06c06499600100082c000081050020b0000010580000c988d9f5905b060080f698600100082c000081050020b0000010580000020b004060010020b0000004160080c0020040600100082c000081050020b0000010580000020b004060010020b0000004160080c0020040600100082c000081050080c0020010580000020b004060010020b0000004160080c0020040600100082c000081050080c0020010580000020b000081050020b0000004160080c0020040600100082c000081050080c0020010580000020b000081050020b0000004160000020b0040600100082c00008105004003ff07c3242a5904d27ec50000000049454e44ae4260826898a02800000000001976a9143ed63e4ca07a9daff855a2a691757f24388fd88e88ac00000000`)
if err != nil {
t.Fatalf("error occurred: %s", err)
}
bmapTx, err := NewFromTx(tx)
if err != nil {
t.Fatalf("error occurred: %s", err)
} else if len(bmapTx.Ord) != 1 {
t.Fatalf("Ord Failed %v", bmapTx)
}
}
func TestRun(t *testing.T) {
r := "run"
zero5 := "05"
data := "{\"in\":5,\"ref\":[\"303ab9e7941ad08482f876a4501116c57a2f3eacf8608b3de235525daf81b357_o1\",\"c2c4c971e85b499c29a8ab2148fd324fe12b550b8f4f57658a4686e011d8fd58_o1\",\"cfa749424a1547a169d0b8fc0a54fed8918d2cf46eeea242fd2aebe3c8875a3c_o1\",\"a9082e00bbedfc80986c7821ed0b2a81dd34ad6bbd2a07fd9e5a06394614a957_o1\",\"705d8340b64e73fa9758e7f7799d28da38669fe0e2cb1ce1960abb1a6a26acf3_o1\",\"92f78b159c4e51ad52ed6d041d2253c2683d95d63a1568e3ce1e8ea516bfb962_o1\",\"08f34f29fd07850ca66973784362927523ea7940084fbd3690676b81628f8c07_o1\",\"d67bf5454d02dafcb4350e65899d890a0660e51442dc0c0f6f7b256a85d19eac_o1\",\"14e278c68ff521e0916ad7c713ae4a0156e76361dbd3b2b357dfb6028e0dca7a_o1\",\"01b37806b3ef4d45f0a73bfe10e916d4f280f9628569765e638259afeb15da16_o1\",\"918d80459b2469381fa493c10bb42d0cdca465170b9d8f88d7c85c55940b8bbc_o1\",\"a78f5a6d72f78711e66c6211fbbd0a0bfd15ad91bdd00404928a9facc63da6d9_o1\",\"74a9d9eddee3fada42489b9db04ef362043225d70799cbfa32a0fc425892ad31_o1\",\"3a67cec3c16bdb847b972bee2fc1c0717c59edcae7bf5f48c91feccfa635af33_o1\",\"382713c2b7abf570b1d344ebcf6b7896d8c5d8fd6362735c5fe72ed793829670_o1\"],\"out\":[\"e0eceb4e317aee7e68e39f22724bb6242c6b79e00483cb4b0250469235bb1ce8\",\"6720ce1b1eeb8401a4258aaab51be88f947744b935c9d7d7eed7c1e8306c8dd3\",\"dee4f6758363d2adfb614783305f6135c13f47772231dbb318d795c5d64d2fac\",\"add7d36d4ab36b1b2e922aa0a21500f3e1a89cd99b80a91acc75ffadd9ee248b\",\"fd86dc04c8a6657e3643a6eaa23892a89e87c481243effb3a22b8e118928e103\",\"df77a80e8a1a950a2cbf6dcc717a7ee461e741d8350edb6fb7aaa35fbf59036f\"],\"del\":[],\"cre\":[\"03107feff22788a1fc8357240bf450fd7bca4bd45d5f8bac63818c5a7b67b03876\"],\"exec\":[{\"op\":\"NEW\",\"data\":[{\"$jig\":5},[\"03107feff22788a1fc8357240bf450fd7bca4bd45d5f8bac63818c5a7b67b03876\",{\"allowBots\":true,\"fee\":0,\"lobby\":5,\"playerCount\":1,\"reward\":0,\"rulesId\":\"bot5\",\"tier\":3},[{\"fighter\":{\"$jig\":0},\"items\":[{\"$jig\":1},{\"$jig\":2},{\"$und\":1},{\"$jig\":3}],\"owner\":\"1Pm9cCc9RnZnAdqbKnXgqbeauRa5nfAejz\",\"pubkey\":\"038630f8220616856e7ebb73847643b4fe39fdcb4d7145b687ed1bb78340c77e08\",\"skills\":[{\"$jig\":7},{\"$jig\":8},{\"$jig\":9},{\"$jig\":10}],\"tags\":[],\"userId\":\"exgen\"},{\"coins\":[],\"fighter\":{\"$jig\":4},\"items\":[],\"pubkey\":\"02c74b8db80b5af8dc9fe14fdc098d3b7073184485471df9cf243330ae8da67a98\",\"skills\":[{\"$dup\":[\"1\",\"2\",\"0\",\"skills\",\"0\"]}],\"tags\":[\"bot\"],\"userId\":\"cryptoFights\"}],\"14ad8af5a501229178217f8f85d698fef13ecaa56c80778cc9d9b1faade4030f\",1622457372560]]}]}"
tape := bpu.Tape{
Cell: []bpu.Cell{
{S: &r},
{H: &zero5},
{S: &cryptoFights},
{S: &data},
},
}
runTx, err := run.NewFromTape(tape)
if err != nil {
t.Fatalf("error occurred: %s", err)
} else if runTx.AppID != cryptoFights {
t.Fatalf("Unexpected data %s %s", runTx.AppID, err)
}
}
func TestRunFromTx(t *testing.T) {
rawTx := "01000000012f92dc3a6c88a574503dc67302bfafc02753e4a35939d25d628855e63a16e217020000006b4830450221009da02e3fb4e758f786fe0713c83eb4cc0dd4fe7cadfcfadfcec67b92534cddd6022029ea80e3b016d8b26970a720c20bc79d3f10bdeb49c7e00e37248336a69b2cd1412103b37a603250b7e37ea6515f01749d9dc58e4723875011370a1abd3f1537ca38cfffffffff030000000000000000fd131f006a0372756e01050c63727970746f6669676874734dfb1e7b22696e223a302c22726566223a5b22323237373530643430303665323939306464346236633239356439306332353538663130663235623032343436373737623130666361303866353565343862335f6f31222c22656366393231306166333535353165643737313965396635316235616265366464633339336162346161373765656462346633336334316465666465383531305f6f31222c22373461396439656464656533666164613432343839623964623034656633363230343332323564373037393963626661333261306663343235383932616433315f6f31222c22373830616131306132323335333235353033383331373364303431343837323531366263323431613735343233643535366631636235373136356138383735645f6f31222c22333832373133633262376162663537306231643334346562636636623738393664386335643866643633363237333563356665373265643739333832393637305f6f31222c22613738663561366437326637383731316536366336323131666262643061306266643135616439316264643030343034393238613966616363363364613664395f6f31222c22313465323738633638666635323165303931366164376337313361653461303135366537363336316462643362326233353764666236303238653064636137615f6f31222c22643637626635343534643032646166636234333530653635383939643839306130363630653531343432646330633066366637623235366138356431396561635f6f31222c22633263346339373165383562343939633239613861623231343866643332346665313262353530623866346635373635386134363836653031316438666435385f6f31222c22336136376365633363313662646238343762393732626565326663316330373137633539656463616537626635663438633931666563636661363335616633335f6f31222c22373166626133383633343162393332333830656335626665646333613430626365343364343937346465636463393463343139613934613863653564666332335f6f31222c22333430643437633238613262386536653836373537653832646130623431323734643333633539663134336431303735316538363364313361396630663531615f6f31225d2c226f7574223a5b2236646132333764343161396638653163646631396335393737383961356661383963636330393430386464616231316537386464373863333231656161626639225d2c2264656c223a5b5d2c22637265223a5b223141467161436751666a3244344371584a46347a7a424d3836596e584b58637458225d2c2265786563223a5b7b226f70223a224445504c4f59222c2264617461223a5b22636c61737320426174746c6520657874656e6473204679784a6967207b5c6e20202020696e69742876616c696461746f722c2072756c65732c20706c61796572732c2069642c2074696d657374616d7029207b5c6e2020202020202020746869732e6964203d20746869732e72616e646f6d203d2069643b5c6e2020202020202020746869732e74696d657374616d70203d2074696d657374616d703b5c6e2020202020202020746869732e72756c6573203d2072756c65733b5c6e5c6e2020202020202020746869732e626174746c65506c6179657273203d20706c61796572732e6d617028706c61796572203d3e20746869732e6a6f696e426174746c6528706c6179657229293b5c6e2020202020202020746869732e626174746c6567726f756e6454696572203d2072756c65732e746965723b5c6e2020202020202020746869732e64696365203d206e65772044696365286964293b5c6e2020202020202020746869732e7374617465203d20426174746c655574696c732e6275696c64426174746c65537461746528746869732e626174746c65506c61796572732c20746869732e64696365293b5c6e5c6e2020202020202020746869732e7475726e436f756e74203d20303b5c6e5c6e2020202020202020746869732e7361746f73686973203d2072756c65732e726577617264207c7c203534363b5c6e5c6e2020202020202020746869732e737461746548617368203d205368613235362e68617368546f486578284a534f4e2e737472696e6769667928746869732e737461746529293b5c6e2020202020202020746869732e737461747573203d20436f6e7374616e74732e5374617475732e4f70656e3b5c6e2020202020202020746869732e7374617465486973746f7279203d205b5d3b5c6e2020202020202020746869732e6163746f72203d20706c61796572735b746869732e73746174652e706c61796572546f4163745d2e7573657249643b5c6e2020202020202020746869732e7374616765203d202763726561746564273b5c6e20202020202020205c6e2020202020202020746869732e6f776e6572203d20746869732e76616c696461746f72203d2076616c696461746f723b5c6e202020207d5c6e5c6e202020206a6f696e426174746c6528706c6179657229207b5c6e2020202020202020636f6e7374207b207573657249642c207075626b65792c206f776e65722c206974656d732c20666967687465722c20736b696c6c732c2074616773207d203d20706c617965723b5c6e20202020202020205c6e2020202020202020696628746869732e72756c65732e66656529207b5c6e20202020202020202020202069662028666967687465722e7361746f73686973203c20746869732e72756c65732e66656529207468726f77206e6577204572726f722827496e73756666696369656e742046696768746572205361746f7368697327293b5c6e202020202020202020202020666967687465722e7365745361746f7368697328666967687465722e7361746f73686973202d20746869732e72756c65732e666565293b5c6e20202020202020207d20656c7365207b5c6e202020202020202020202020666967687465722e6175746828293b5c6e20202020202020207d5c6e20202020202020205c6e20202020202020206974656d732e666f7245616368286974656d203d3e206974656d202626206974656d2e617574682829293b5c6e2020202020202020636f6e7374205b6d61696e68616e642c206f666668616e642c2061726d6f722c206861745d203d206974656d732e6d61702869203d3e206920262620692e6974656d20262620467978436c6173732e64656570436c6f6e6528692e6974656d29293b5c6e5c6e202020202020202072657475726e207b5c6e2020202020202020202020207573657249642c5c6e2020202020202020202020207075626b65792c5c6e2020202020202020202020206f776e65722c5c6e202020202020202020202020666967687465722c5c6e2020202020202020202020206d61696e68616e642c5c6e2020202020202020202020206f666668616e642c5c6e20202020202020202020202061726d6f722c5c6e2020202020202020202020206861742c5c6e202020202020202020202020736b696c6c732c5c6e202020202020202020202020746167733a2074616773207c7c205b5d5c6e20202020202020207d3b5c6e202020207d5c6e5c6e20202020626567696e2874696d656f757429207b5c6e202020202020202069662028746869732e737461676520213d3d2027637265617465642729207468726f77206e6577204572726f722827496e76616c696420537461676527293b5c6e2020202020202020746869732e74696d656f7574203d2074696d656f75743b5c6e202020202020202064656c65746520746869732e73746167653b5c6e2020202020202020746869732e616374696f6e546f6b656e203d206e657720416374696f6e546f6b656e28746869732e6f776e65722c20746869732e626174746c65506c61796572735b746869732e73746174652e706c61796572546f4163745d2e666967687465722e6f776e6572293b5c6e202020207d5c6e5c6e202020207265736f6c76652872616e646f6d2c2074696d657374616d702c2074696d656f757429207b5c6e20202020202020202f2f20636f6e736f6c652e6c6f6728275265736f6c7665272c20746869732e6c6f636174696f6e293b5c6e202020202020202069662028746869732e73746174757320213d3d20436f6e7374616e74732e5374617475732e4f70656e29207468726f77206e6577204572726f722827496e76616c69642053746174757327293b5c6e20202020202020206966202821426174746c655574696c732e76616c696461746552616e646f6d2872616e646f6d2c20746869732e72616e646f6d2929207468726f77206e6577204572726f722827496e76616c69642052616e646f6d27293b5c6e2020202020202020746869732e72616e646f6d203d2072616e646f6d3b5c6e20202020202020205c6e2020202020202020746869732e7374617465486973746f72795b746869732e7475726e436f756e745d203d20746869732e676574537461746528293b5c6e2020202020202020636f6e7374207374617465203d20467978436c6173732e64656570436c6f6e6528746869732e7374617465293b5c6e202020202020202073746174652e616374696f6e4c6f6773203d205b5d3b5c6e2020202020202020746869732e64696365203d206e657720446963652872616e646f6d293b5c6e2020202020202020636f6e737420616374696f6e496e646578203d20746869732e616374696f6e546f6b656e2e616374696f6e496e6465783b5c6e20202020202020206966202874696d657374616d70203c20746869732e74696d656f757429207b5c6e20202020202020202020202069662028616374696f6e496e646578203d3d3d202d31207c7c20616374696f6e496e646578203d3d3d20756e646566696e656429207b5c6e20202020202020202020202020202020746869732e7374617465203d20426174746c655574696c732e736b69705475726e28746869732c2073746174652c20746869732e646963652c2074696d657374616d70293b5c6e2020202020202020202020207d20656c7365207b5c6e20202020202020202020202020202020746869732e616374696f6e546f6b656e2e64657374726f7928293b5c6e20202020202020202020202020202020636f6e73742061747461636b6572203d20746869732e626174746c65506c61796572735b746869732e73746174652e706c61796572546f4163745d3b5c6e20202020202020202020202020202020636f6e737420736b696c6c203d2061747461636b65722e736b696c6c735b616374696f6e496e6465785d3b5c6e202020202020202020202020202020206966202821736b696c6c29207468726f77206e6577204572726f722860247b61747461636b65722e666967687465722e646973706c61794e616d657d207573656420616e20696e76616c696420536b696c6c2049443a20247b616374696f6e496e6465787d60293b5c6e20202020202020202020202020202020746869732e7374617465203d20736b696c6c2e72756e28746869732c2073746174652c20746869732e646963652c2074696d657374616d70293b5c6e2020202020202020202020207d5c6e20202020202020207d20656c7365207b5c6e202020202020202020202020746869732e7374617465203d20426174746c655574696c732e736b69705475726e28746869732c2073746174652c20746869732e646963652c2074696d657374616d70293b5c6e20202020202020207d5c6e5c6e2020202020202020746869732e737461747573203d20746869732e73746174652e7374617475733b5c6e2020202020202020746869732e74696d657374616d70203d2074696d657374616d703b5c6e2020202020202020746869732e74696d656f7574203d2074696d656f75743b5c6e2020202020202020746869732e5f656e645475726e28293b5c6e202020207d5c6e5c6e20202020666f7266656974286d6573736167652c2074696d657374616d7029207b5c6e202020202020202069662028746869732e73746174757320213d3d20436f6e7374616e74732e5374617475732e4f70656e29207468726f77206e6577204572726f722827496e76616c69642053746174757327293b5c6e2020202020202020746869732e7374617465486973746f72795b746869732e7475726e436f756e745d203d20746869732e676574537461746528293b5c6e2020202020202020636f6e737420706c61796572496e646578203d20746869732e626174746c65506c61796572732e66696e64496e6465782870203d3e20702e757365724964203d3d3d206d6573736167652e66726f6d293b5c6e2020202020202020636f6e737420706c61796572203d20746869732e626174746c65506c61796572735b706c61796572496e6465785d3b5c6e2020202020202020636f6e737420766963746f72496e646578203d20746869732e626174746c65506c61796572732e66696e64496e6465782870203d3e20702e75736572496420213d3d206d6573736167652e66726f6d293b5c6e2020202020202020636f6e737420766963746f72203d20746869732e626174746c65506c61796572735b766963746f72496e6465785d3b5c6e20202020202020205c6e2020202020202020636f6e7374207374617465203d20467978436c6173732e64656570436c6f6e6528746869732e7374617465293b5c6e202020202020202073746174652e766963746f72203d207b5c6e2020202020202020202020207075626b65793a20766963746f722e7075626b65792c5c6e2020202020202020202020206f776e65723a20766963746f722e6f776e65722c5c6e202020202020202020202020666967687465723a20766963746f722e666967687465722c5c6e2020202020202020202020207573657249643a20766963746f722e7573657249645c6e20202020202020207d3b5c6e202020202020202073746174652e616374696f6e4c6f6773203d205b7b5c6e202020202020202020202020706c61796572496e6465783a20706c61796572496e6465782c5c6e202020202020202020202020616374696f6e4c6f674d6573736167653a20603c6772616469656e743d21706c61796572247b706c61796572496e6465787d2d636f6c6f723e3c623e247b706c617965722e666967687465722e6d657461646174612e6e616d652e746f55707065724361736528297d3c2f623e203c6772616469656e743d216c6f672d636f6c6f723e20466f72666569746564605c6e20202020202020207d5d3b5c6e202020202020202073746174652e706c61796572546f416374203d20766963746f72496e6465783b5c6e202020202020202073746174652e737461747573203d20436f6e7374616e74732e5374617475732e466f72666569743b5c6e2020202020202020746869732e7374617465203d2073746174653b5c6e5c6e2020202020202020746869732e737461747573203d20746869732e73746174652e7374617475733b5c6e2020202020202020746869732e74696d657374616d70203d2074696d657374616d703b5c6e2020202020202020746869732e5f656e645475726e28293b5c6e202020207d5c6e5c6e202020205f656e645475726e2829207b5c6e202020202020202069662028746869732e737461747573203d3d3d20436f6e7374616e74732e5374617475732e4f70656e29207b5c6e202020202020202020202020746869732e616374696f6e546f6b656e203d206e657720416374696f6e546f6b656e28746869732e6f776e65722c20746869732e626174746c65506c61796572735b746869732e73746174652e706c61796572546f4163745d2e666967687465722e6f776e6572293b5c6e20202020202020207d20656c7365207b5c6e202020202020202020202020746869732e766963746f72203d207b2e2e2e746869732e626174746c65506c61796572735b746869732e73746174652e706c61796572546f4163745d7d3b5c6e20202020202020207d5c6e2020202020202020746869732e7475726e436f756e742b2b3b5c6e2020202020202020746869732e737461746548617368203d205368613235362e68617368546f486578284a534f4e2e737472696e6769667928746869732e737461746529293b5c6e2020202020202020746869732e6163746f72203d20746869732e626174746c65506c61796572735b746869732e73746174652e706c61796572546f4163745d2e7573657249643b5c6e202020207d5c6e5c6e2020202066696e616c697a652829207b5c6e2020202020202020746869732e7374617465486973746f72795b746869732e7475726e436f756e745d203d20746869732e676574537461746528293b5c6e2020202020202020696628215b436f6e7374616e74732e5374617475732e436f6d706c6574652c20436f6e7374616e74732e5374617475732e466f72666569745d2e696e636c7564657328746869732e7374617475732929207468726f77206e6577204572726f722827496e76616c69642053746174757327293b5c6e2020202020202020636f6e737420766963746f72203d20746869732e766963746f723b5c6e2020202020202020636f6e7374206c6f736572203d20746869732e626174746c65506c61796572732e66696e642870203d3e20702e75736572496420213d3d20766963746f722e757365724964293b5c6e2020202020202020746869732e7870203d20426174746c652e4c6576656c58505265776172645b6c6f7365722e666967687465722e6c6576656c5d3b5c6e20202020202020205c6e20202020202020206966202821766963746f722e746167732e696e636c756465732827626f74272929207b5c6e202020202020202020202020636f6e7374206974656d73203d2069737375655265776172647328746869732e646963652c20746869732e626174746c6567726f756e6454696572293b5c6e202020202020202020202020746869732e72657761726473203d206974656d732e6d61702869203d3e206e6577204679784974656d28766963746f722e666967687465722e6f776e65722c20692e6d657461646174612c20692e6974656d2c20692e7361746f7368697329293b5c6e20202020202020207d5c6e20202020202020205c6e2020202020202020746869732e626174746c65506c61796572732e666f724561636828706c61796572203d3e206e657720426174746c65546f6b656e28706c617965722e666967687465722e6f776e657229293b5c6e2020202020202020746869732e6f776e6572203d20766963746f722e666967687465722e6f776e65723b5c6e2020202020202020746869732e737461747573203d20436f6e7374616e74732e5374617475732e46696e616c697a65643b5c6e202020207d5c6e202020205c6e2020202067657453746174652829207b5c6e2020202020202020636f6e7374207374617465203d207b5c6e2020202020202020202020202e2e2e746869732e73746174652c5c6e2020202020202020202020206c6f636174696f6e3a20746869732e6f726967696e2c5c6e2020202020202020202020206f726967696e3a20746869732e6f726967696e2c5c6e2020202020202020202020206163746f723a20746869732e6163746f722c5c6e202020202020202020202020626174746c6549643a20746869732e69642c5c6e20202020202020202020202072616e646f6d3a20746869732e72616e646f6d2c5c6e2020202020202020202020207374617465486173683a20746869732e7374617465486173682c5c6e20202020202020202020202074696d657374616d703a20746869732e74696d657374616d702c5c6e2020202020202020202020207475726e436f756e743a20746869732e7475726e436f756e742c5c6e20202020202020202020202074696d656f75743a20746869732e74696d656f75742c5c6e202020202020202020202020626174746c655374617475733a20746869732e7374617475735c6e20202020202020207d3b5c6e202020202020202072657475726e2073746174653b5c6e202020207d5c6e7d222c7b224c6576656c5850526577617264223a5b302c3130302c3230302c3330302c3630302c313230302c323430302c302c302c3535362c3731332c3931332c313137302c313439382c313931392c323435382c333134382c343033322c353136342c363631342c383437325d2c224d6178526f756e6473223a3130302c2264657073223a7b22416374696f6e546f6b656e223a7b22246a6967223a307d2c22426174746c65546f6b656e223a7b22246a6967223a317d2c22426174746c655574696c73223a7b22246a6967223a327d2c22436f6e666967223a7b22246a6967223a337d2c22436f6e7374616e7473223a7b22246a6967223a347d2c2244696365223a7b22246a6967223a357d2c22467978436c617373223a7b22246a6967223a367d2c224679784974656d223a7b22246a6967223a377d2c224679784a6967223a7b22246a6967223a387d2c22536861323536223a7b22246a6967223a397d2c22657870656374223a7b22246a6967223a31307d2c22697373756552657761726473223a7b22246a6967223a31317d7d2c2268617368223a2232343231326337333838313564313331636233366430373035333962353661393835643261336530306134363166646139376237663461363834663163636630222c226d65746164617461223a7b22617070223a2243727970746f666967687473222c22656d6f6a69223a22e29a94222c226e616d65223a22426174746c65222c227075626c6973686572223a22465958227d7d5d7d5d7d11010000000000001976a91401c0211c753075df61c7ac9b25669e1799fd386e88ac869d0100000000001976a914de1bdee715a6e84d31f6bc1b9986b6a15aefc10c88ac00000000"
tx, err := transaction.NewTransactionFromHex(rawTx)
if err != nil {
t.Fatalf("Failed to parse: %s", err)
}
// t.Fatalf(tx.GetTxID())
runTx, err := run.NewFromUtxo(tx.Outputs[0])
if err != nil {
t.Fatalf("error occurred: %s", err)
} else if runTx.AppID != cryptoFights {
t.Fatalf("Unexpected data %s", runTx.AppID)
}
if runTx.Payload.Exec[0].Op != run.DEPLOY {
t.Fatalf("Failed to read Run Statement %+v", runTx.Payload.Exec[0])
}
}
func TestB(t *testing.T) {
helloWorld := "Hello world"
mimeType := "text/plain"
encoding := "utf8"
prefix := b.Prefix
tape := bpu.Tape{
Cell: []bpu.Cell{
{S: &prefix},
{S: &helloWorld},
{S: &mimeType},
{S: &encoding},
},
}
bTx, err := b.NewFromTape(tape)
if err != nil {
t.Fatalf("error occurred: %s", err)
} else if bTx.Data.UTF8 != "Hello world" {
t.Fatalf("Unexpected data %s %s", bTx.Data.UTF8, err)
}
}
func TestNewFromBob(t *testing.T) {
bobTx, err := bob.NewFromString(sampleValidBobTx)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
var bMap *Tx
bMap, err = NewFromBob(bobTx)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
if bMap.BAP[0].Type != bap.ATTEST {
t.Fatalf("expected: %s but got: %s", bap.ATTEST, bMap.BAP[0].Type)
}
if bMap.AIP[0].Signature != "H+lubfcz5Z2oG8B7HwmP8Z+tALP+KNOPgedo7UTXwW8LBpMkgCgatCdpvbtf7wZZQSIMz83emmAvVS4S3F5X1wo=" {
t.Fatalf("expected: %s but got: %s", "H+lubfcz5Z2oG8B7HwmP8Z+tALP+KNOPgedo7UTXwW8LBpMkgCgatCdpvbtf7wZZQSIMz83emmAvVS4S3F5X1wo=", bMap.AIP[0].Signature)
}
}
func TestNewFromRawTxString(t *testing.T) {
testHex := test.GetTestHex("./test/tx/42097dce22e3371493fe4ad63424abcf3aa31309b41a290debd3ccf7e4a6bef4.hex")
bobTx, err := bob.NewFromRawTxString(testHex)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
var bMap *Tx
bMap, err = NewFromBob(bobTx)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
if bMap.B[1].MediaType != "image/gif" {
t.Fatalf("expected: image/gif but got: %s", bMap.B[1].MediaType)
}
if bMap.B[0].MediaType != "text/markdown" {
t.Fatalf("expected: text/markdown but got: %s", bMap.B[0].MediaType)
}
if bMap.AIP[0].Signature != "HwGOmQsMhgz4U6EqWk2Kd5SyFMIf14sjLzTOlCBBwCvlckDAuR743e+gMUUP63letFQH7zZY3u6y6r19X35u4yA=" {
t.Fatalf("expected: %s but got: %s", "HwGOmQsMhgz4U6EqWk2Kd5SyFMIf14sjLzTOlCBBwCvlckDAuR743e+gMUUP63letFQH7zZY3u6y6r19X35u4yA=", bMap.AIP[0].Signature)
}
}
func TestNewOrdFromRawTxString(t *testing.T) {
testHex := test.GetTestHex("./test/tx/ord.hex")
bobTx, err := bob.NewFromRawTxString(testHex)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
var bMap *Tx
bMap, err = NewFromBob(bobTx)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
if bMap.Ord[0].ContentType != "model/gltf-binary" {
t.Fatalf("expected: model/gltf-binary but got: %s", bMap.B[0].MediaType)
}
}
func TestHugeOrdFromRawTxString(t *testing.T) {
testHex := test.GetTestHex("./test/tx/c8cd6ff398d23e12e65ab065757fe6caf2d74b5e214b638365d61583030aa069.hex")
bobTx, err := bob.NewFromRawTxString(testHex)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
var bMap *Tx
bMap, err = NewFromBob(bobTx)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
if bMap.Ord[0].ContentType != "image/png" {
t.Fatalf("expected: image/png but got: %s", bMap.B[0].MediaType)
}
}
func TestHugeOrdFromTx(t *testing.T) {
testHex := test.GetTestHex("./test/tx/c8cd6ff398d23e12e65ab065757fe6caf2d74b5e214b638365d61583030aa069.hex")
btTx, err := transaction.NewTransactionFromHex(testHex)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
var bMap *Tx
bMap, err = NewFromTx(btTx)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
// dType := utils.GetDestinationType(btTx)
// if dType != utils.ScriptTypeNullData {
// t.Fatalf("expected: null data but got: %s", &dType)
// }
if len(bMap.Ord) != 1436 {
t.Fatalf("expected: 1436 ord but got: %d", len(bMap.Ord))
}
if bMap.Ord[0].ContentType != "image/png" {
t.Fatalf("expected: image/png but got: %s", bMap.Ord[0].ContentType)
}
}
func TestBadTape(t *testing.T) {
testHex := test.GetTestHex("./test/tx/boost.hex")
bobTx, err := bob.NewFromRawTxString(testHex)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
bPrefix := b.Prefix
bobTx.Out = []bpu.Output{
{
XPut: bpu.XPut{
I: 0,
Tape: []bpu.Tape{{
Cell: []bpu.Cell{{
H: nil,
S: &bPrefix,
B: nil,
Op: nil,
Ops: nil,
I: 0,
II: 0,
LS: nil,
LB: nil,
}},
I: 0,
}},
E: bpu.E{
A: nil,
V: nil,
I: 0,
H: nil,
},
},
}}
bobTx.In = []bpu.Input{}
bMap, err := NewFromBob(bobTx)
if err == nil {
t.Fatal("an error was expected")
}
if bMap != nil {
t.Fatal("bmap tx was not nil", err)
}
}
func TestNewBoostFromRawTxString(t *testing.T) {
testHex := test.GetTestHex("./test/tx/boost.hex")
bobTx, err := bob.NewFromRawTxString(testHex)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
var bMap *Tx
bMap, err = NewFromBob(bobTx)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
if len(bMap.BOOST) != 1 {
t.Fatalf("expected: %d boost but got: %d", 1, len(bMap.BOOST))
}
}
func TestBreakerFromRawTxString(t *testing.T) {
testHex := test.GetTestHex("./test/tx/b9c57c18677922e206325d03dabb566a3dfd5eaf674232c2b53554e7d5abe32b.hex")
bobTx, err := bob.NewFromRawTxString(testHex)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
var bMap *Tx
bMap, err = NewFromBob(bobTx)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
if bMap.Tx.Tx.H != "b9c57c18677922e206325d03dabb566a3dfd5eaf674232c2b53554e7d5abe32b" {
t.Fatalf("expected: %s but got: %s", "b9c57c18677922e206325d03dabb566a3dfd5eaf674232c2b53554e7d5abe32b", bMap.Tx.Tx.H)
}
}
func TestBreaker3FromRawTxString(t *testing.T) {
testHex := test.GetTestHex("./test/tx/662104c5bb6a9e912f260795f5d770e670f0a966bc6fd89fe8c0e88fc78e8378.hex")
bobTx, err := bob.NewFromRawTxString(testHex)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
var bMap *Tx
bMap, err = NewFromBob(bobTx)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
if bMap.Tx.Tx.H != "662104c5bb6a9e912f260795f5d770e670f0a966bc6fd89fe8c0e88fc78e8378" {
t.Fatalf("expected: %s but got: %s", "662104c5bb6a9e912f260795f5d770e670f0a966bc6fd89fe8c0e88fc78e8378", bMap.Tx.Tx.H)
}
if bMap.Ord == nil {
t.Fatalf("no ord found")
}
}
func TestBreaker2FromRawTxString(t *testing.T) {
testHex := test.GetTestHex("./test/tx/75a307aa68182d06a079fb2274a5ca439c1f5cc93f01fed3dd5dee6a407ba21c.hex")
bobTx, err := bob.NewFromRawTxString(testHex)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
var bMap *Tx
bMap, err = NewFromBob(bobTx)
if err != nil {
t.Fatalf("error occurred: %s", err.Error())
}
if bMap.Tx.Tx.H != "75a307aa68182d06a079fb2274a5ca439c1f5cc93f01fed3dd5dee6a407ba21c" {
t.Fatalf("expected: %s but got: %s", "75a307aa68182d06a079fb2274a5ca439c1f5cc93f01fed3dd5dee6a407ba21c", bMap.Tx.Tx.H)
}
}
// TODO: make this test pass
// func TestBreaker4FromRawTxString(t *testing.T) {
// testHex := test.GetTestHex("./test/tx/870f7abb189530ea475bcd87c599ad9370fd8d8be290e20ad0548af6de4bb8df.hex")
// bobTx, err := bob.NewFromRawTxString(testHex)
// if err != nil {
// t.Fatalf("error occurred: %s", err.Error())
// }
// var bMap *Tx
// bMap, err = NewFromBob(bobTx)
// if err != nil {
// t.Fatalf("error occurred: %s", err.Error())
// }
// if bMap.Tx.Tx.H != "870f7abb189530ea475bcd87c599ad9370fd8d8be290e20ad0548af6de4bb8df" {
// t.Fatalf("expected: %s but got: %s", "870f7abb189530ea475bcd87c599ad9370fd8d8be290e20ad0548af6de4bb8df", bMap.Tx.Tx.H)
// }
// }