@@ -208,7 +208,7 @@ func TestGetMetrics(t *testing.T) {
208208 assert .Equal (t , & types.Metrics {
209209 HitsFsCache : 1 ,
210210 ElementsMemoryCache : 1 ,
211- SizeMemoryCache : 3432787 ,
211+ SizeMemoryCache : 2953616 ,
212212 }, metrics )
213213
214214 // Instantiate 2
@@ -223,7 +223,7 @@ func TestGetMetrics(t *testing.T) {
223223 HitsMemoryCache : 1 ,
224224 HitsFsCache : 1 ,
225225 ElementsMemoryCache : 1 ,
226- SizeMemoryCache : 3432787 ,
226+ SizeMemoryCache : 2953616 ,
227227 }, metrics )
228228
229229 // Pin
@@ -238,8 +238,8 @@ func TestGetMetrics(t *testing.T) {
238238 HitsFsCache : 1 ,
239239 ElementsPinnedMemoryCache : 1 ,
240240 ElementsMemoryCache : 1 ,
241- SizePinnedMemoryCache : 3432787 ,
242- SizeMemoryCache : 3432787 ,
241+ SizePinnedMemoryCache : 2953616 ,
242+ SizeMemoryCache : 2953616 ,
243243 }, metrics )
244244
245245 // Instantiate 3
@@ -256,8 +256,8 @@ func TestGetMetrics(t *testing.T) {
256256 HitsFsCache : 1 ,
257257 ElementsPinnedMemoryCache : 1 ,
258258 ElementsMemoryCache : 1 ,
259- SizePinnedMemoryCache : 3432787 ,
260- SizeMemoryCache : 3432787 ,
259+ SizePinnedMemoryCache : 2953616 ,
260+ SizeMemoryCache : 2953616 ,
261261 }, metrics )
262262
263263 // Unpin
@@ -274,7 +274,7 @@ func TestGetMetrics(t *testing.T) {
274274 ElementsPinnedMemoryCache : 0 ,
275275 ElementsMemoryCache : 1 ,
276276 SizePinnedMemoryCache : 0 ,
277- SizeMemoryCache : 3432787 ,
277+ SizeMemoryCache : 2953616 ,
278278 }, metrics )
279279
280280 // Instantiate 4
@@ -292,7 +292,7 @@ func TestGetMetrics(t *testing.T) {
292292 ElementsPinnedMemoryCache : 0 ,
293293 ElementsMemoryCache : 1 ,
294294 SizePinnedMemoryCache : 0 ,
295- SizeMemoryCache : 3432787 ,
295+ SizeMemoryCache : 2953616 ,
296296 }, metrics )
297297}
298298
@@ -319,7 +319,7 @@ func TestInstantiate(t *testing.T) {
319319 res , cost , err := Instantiate (cache , checksum , env , info , msg , & igasMeter , store , api , & querier , TESTING_GAS_LIMIT , TESTING_PRINT_DEBUG )
320320 require .NoError (t , err )
321321 requireOkResponse (t , res , 0 )
322- assert .Equal (t , uint64 (0x8e99 ), cost )
322+ assert .Equal (t , uint64 (0x85b0 ), cost )
323323
324324 var result types.ContractResult
325325 err = json .Unmarshal (res , & result )
@@ -350,7 +350,7 @@ func TestExecute(t *testing.T) {
350350 diff := time .Now ().Sub (start )
351351 require .NoError (t , err )
352352 requireOkResponse (t , res , 0 )
353- assert .Equal (t , uint64 (0x8e99 ), cost )
353+ assert .Equal (t , uint64 (0x85b0 ), cost )
354354 t .Logf ("Time (%d gas): %s\n " , cost , diff )
355355
356356 // execute with the same store
@@ -363,7 +363,7 @@ func TestExecute(t *testing.T) {
363363 res , cost , err = Execute (cache , checksum , env , info , []byte (`{"release":{}}` ), & igasMeter2 , store , api , & querier , TESTING_GAS_LIMIT , TESTING_PRINT_DEBUG )
364364 diff = time .Now ().Sub (start )
365365 require .NoError (t , err )
366- assert .Equal (t , uint64 (0xef2c ), cost )
366+ assert .Equal (t , uint64 (0xf043 ), cost )
367367 t .Logf ("Time (%d gas): %s\n " , cost , diff )
368368
369369 // make sure it read the balance properly and we got 250 atoms
@@ -372,7 +372,16 @@ func TestExecute(t *testing.T) {
372372 require .NoError (t , err )
373373 require .Equal (t , "" , result .Err )
374374 require .Equal (t , 1 , len (result .Ok .Messages ))
375- dispatch := result .Ok .Messages [0 ]
375+
376+ // Ensure we got our custom event
377+ assert .Equal (t , len (result .Ok .Events ), 1 )
378+ ev := result .Ok .Events [0 ]
379+ assert .Equal (t , ev .Type , "hackatom" )
380+ assert .Equal (t , len (ev .Attributes ), 1 )
381+ assert .Equal (t , ev .Attributes [0 ].Key , "action" )
382+ assert .Equal (t , ev .Attributes [0 ].Value , "release" )
383+
384+ dispatch := result .Ok .Messages [0 ].Msg
376385 require .NotNil (t , dispatch .Bank , "%#v" , dispatch )
377386 require .NotNil (t , dispatch .Bank .Send , "%#v" , dispatch )
378387 send := dispatch .Bank .Send
@@ -405,7 +414,7 @@ func TestExecuteCpuLoop(t *testing.T) {
405414 diff := time .Now ().Sub (start )
406415 require .NoError (t , err )
407416 requireOkResponse (t , res , 0 )
408- assert .Equal (t , uint64 (0x8e99 ), cost )
417+ assert .Equal (t , uint64 (0x85b0 ), cost )
409418 t .Logf ("Time (%d gas): %s\n " , cost , diff )
410419
411420 // execute a cpu loop
@@ -556,7 +565,7 @@ func TestMultipleInstances(t *testing.T) {
556565 require .NoError (t , err )
557566 requireOkResponse (t , res , 0 )
558567 // we now count wasm gas charges and db writes
559- assert .Equal (t , uint64 (0x8d78 ), cost )
568+ assert .Equal (t , uint64 (0x84ad ), cost )
560569
561570 // instance2 controlled by mary
562571 gasMeter2 := NewMockGasMeter (TESTING_GAS_LIMIT )
@@ -567,14 +576,14 @@ func TestMultipleInstances(t *testing.T) {
567576 res , cost , err = Instantiate (cache , checksum , env , info , msg , & igasMeter2 , store2 , api , & querier , TESTING_GAS_LIMIT , TESTING_PRINT_DEBUG )
568577 require .NoError (t , err )
569578 requireOkResponse (t , res , 0 )
570- assert .Equal (t , uint64 (0x8e1d ), cost )
579+ assert .Equal (t , uint64 (0x8541 ), cost )
571580
572581 // fail to execute store1 with mary
573- resp := exec (t , cache , checksum , "mary" , store1 , api , querier , 0x79ee )
582+ resp := exec (t , cache , checksum , "mary" , store1 , api , querier , 0x75ab )
574583 require .Equal (t , "Unauthorized" , resp .Err )
575584
576585 // succeed to execute store1 with fred
577- resp = exec (t , cache , checksum , "fred" , store1 , api , querier , 0xeeb8 )
586+ resp = exec (t , cache , checksum , "fred" , store1 , api , querier , 0xefcf )
578587 require .Equal (t , "" , resp .Err )
579588 require .Equal (t , 1 , len (resp .Ok .Messages ))
580589 attributes := resp .Ok .Attributes
@@ -583,7 +592,7 @@ func TestMultipleInstances(t *testing.T) {
583592 require .Equal (t , "bob" , attributes [1 ].Value )
584593
585594 // succeed to execute store2 with mary
586- resp = exec (t , cache , checksum , "mary" , store2 , api , querier , 0xeef2 )
595+ resp = exec (t , cache , checksum , "mary" , store2 , api , querier , 0xf009 )
587596 require .Equal (t , "" , resp .Err )
588597 require .Equal (t , 1 , len (resp .Ok .Messages ))
589598 attributes = resp .Ok .Attributes
@@ -627,7 +636,7 @@ func TestSudo(t *testing.T) {
627636 require .NoError (t , err )
628637 require .Equal (t , "" , result .Err )
629638 require .Equal (t , 1 , len (result .Ok .Messages ))
630- dispatch := result .Ok .Messages [0 ]
639+ dispatch := result .Ok .Messages [0 ]. Msg
631640 require .NotNil (t , dispatch .Bank , "%#v" , dispatch )
632641 require .NotNil (t , dispatch .Bank .Send , "%#v" , dispatch )
633642 send := dispatch .Bank .Send
@@ -667,7 +676,7 @@ func TestDispatchSubmessage(t *testing.T) {
667676 }
668677 payloadBin , err := json .Marshal (payload )
669678 require .NoError (t , err )
670- payloadMsg := []byte (fmt .Sprintf (`{"reflect_sub_call ":{"msgs":[%s]}}` , string (payloadBin )))
679+ payloadMsg := []byte (fmt .Sprintf (`{"reflect_sub_msg ":{"msgs":[%s]}}` , string (payloadBin )))
671680
672681 gasMeter2 := NewMockGasMeter (TESTING_GAS_LIMIT )
673682 igasMeter2 := GasMeter (gasMeter2 )
@@ -681,9 +690,8 @@ func TestDispatchSubmessage(t *testing.T) {
681690 err = json .Unmarshal (res , & result )
682691 require .NoError (t , err )
683692 require .Equal (t , "" , result .Err )
684- require .Equal (t , 0 , len (result .Ok .Messages ))
685- require .Equal (t , 1 , len (result .Ok .Submessages ))
686- dispatch := result .Ok .Submessages [0 ]
693+ require .Equal (t , 1 , len (result .Ok .Messages ))
694+ dispatch := result .Ok .Messages [0 ]
687695 assert .Equal (t , id , dispatch .ID )
688696 assert .Equal (t , payload .Msg , dispatch .Msg )
689697 assert .Nil (t , dispatch .GasLimit )
@@ -739,12 +747,12 @@ func TestReplyAndQuery(t *testing.T) {
739747 requireOkResponse (t , res , 0 )
740748
741749 // now query the state to see if it stored the data properly
742- badQuery := []byte (`{"sub_call_result ":{"id":7777}}` )
750+ badQuery := []byte (`{"sub_msg_result ":{"id":7777}}` )
743751 res , _ , err = Query (cache , checksum , env , badQuery , & igasMeter2 , store , api , & querier , TESTING_GAS_LIMIT , TESTING_PRINT_DEBUG )
744752 require .NoError (t , err )
745753 requireQueryError (t , res )
746754
747- query := []byte (`{"sub_call_result ":{"id":1234}}` )
755+ query := []byte (`{"sub_msg_result ":{"id":1234}}` )
748756 res , _ , err = Query (cache , checksum , env , query , & igasMeter2 , store , api , & querier , TESTING_GAS_LIMIT , TESTING_PRINT_DEBUG )
749757 require .NoError (t , err )
750758 qres := requireQueryOk (t , res )
0 commit comments