diff --git a/rpc/test/client_ws_test.go b/rpc/test/client_ws_test.go index 59da51c4..70b21c96 100644 --- a/rpc/test/client_ws_test.go +++ b/rpc/test/client_ws_test.go @@ -190,7 +190,7 @@ func TestWSCallCall(t *testing.T) { // susbscribe to the new contracts amt = int64(10001) - eid1 := types.EventStringAccReceive(contractAddr1) + eid1 := types.EventStringAccCall(contractAddr1) subscribe(t, con, eid1) defer func() { unsubscribe(t, con, eid1) diff --git a/state/permissions_test.go b/state/permissions_test.go index 162fb154..92ed32c4 100644 --- a/state/permissions_test.go +++ b/state/permissions_test.go @@ -385,8 +385,8 @@ func TestCallPermission(t *testing.T) { tx, _ = types.NewCallTx(blockCache, user[0].PubKey, caller1ContractAddr, nil, 100, 10000, 100) tx.Sign(chainID, user[0]) - // we need to subscribe to the Receive event to detect the exception - _, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccReceive(caller1ContractAddr)) // + // we need to subscribe to the Call event to detect the exception + _, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(caller1ContractAddr)) // if exception == "" { t.Fatal("Expected exception") } @@ -401,8 +401,8 @@ func TestCallPermission(t *testing.T) { tx, _ = types.NewCallTx(blockCache, user[0].PubKey, caller1ContractAddr, nil, 100, 10000, 100) tx.Sign(chainID, user[0]) - // we need to subscribe to the Receive event to detect the exception - _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccReceive(caller1ContractAddr)) // + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(caller1ContractAddr)) // if exception != "" { t.Fatal("Unexpected exception:", exception) } @@ -431,8 +431,8 @@ func TestCallPermission(t *testing.T) { tx, _ = types.NewCallTx(blockCache, user[0].PubKey, caller2ContractAddr, nil, 100, 10000, 100) tx.Sign(chainID, user[0]) - // we need to subscribe to the Receive event to detect the exception - _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccReceive(caller1ContractAddr)) // + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(caller1ContractAddr)) // if exception == "" { t.Fatal("Expected exception") } @@ -449,8 +449,8 @@ func TestCallPermission(t *testing.T) { tx, _ = types.NewCallTx(blockCache, user[0].PubKey, caller2ContractAddr, nil, 100, 10000, 100) tx.Sign(chainID, user[0]) - // we need to subscribe to the Receive event to detect the exception - _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccReceive(caller1ContractAddr)) // + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(caller1ContractAddr)) // if exception != "" { t.Fatal("Unexpected exception", exception) } @@ -519,8 +519,8 @@ func TestCreatePermission(t *testing.T) { // A single input, having the permission, should succeed tx, _ = types.NewCallTx(blockCache, user[0].PubKey, contractAddr, createCode, 100, 100, 100) tx.Sign(chainID, user[0]) - // we need to subscribe to the Receive event to detect the exception - _, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccReceive(contractAddr)) // + // we need to subscribe to the Call event to detect the exception + _, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(contractAddr)) // if exception == "" { t.Fatal("expected exception") } @@ -535,8 +535,8 @@ func TestCreatePermission(t *testing.T) { // A single input, having the permission, should succeed tx, _ = types.NewCallTx(blockCache, user[0].PubKey, contractAddr, createCode, 100, 100, 100) tx.Sign(chainID, user[0]) - // we need to subscribe to the Receive event to detect the exception - _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccReceive(contractAddr)) // + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(contractAddr)) // if exception != "" { t.Fatal("unexpected exception", exception) } @@ -562,8 +562,8 @@ func TestCreatePermission(t *testing.T) { // this should call the 0 address but not create ... tx, _ = types.NewCallTx(blockCache, user[0].PubKey, contractAddr, createCode, 100, 10000, 100) tx.Sign(chainID, user[0]) - // we need to subscribe to the Receive event to detect the exception - _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccReceive(zeroAddr)) // + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(zeroAddr)) // if exception != "" { t.Fatal("unexpected exception", exception) } @@ -813,8 +813,8 @@ func TestCreateAccountPermission(t *testing.T) { txCall, _ := types.NewCallTx(blockCache, user[0].PubKey, caller1ContractAddr, nil, 100, 10000, 100) txCall.Sign(chainID, user[0]) - // we need to subscribe to the Receive event to detect the exception - _, exception := execTxWaitEvent(t, blockCache, txCall, types.EventStringAccReceive(caller1ContractAddr)) // + // we need to subscribe to the Call event to detect the exception + _, exception := execTxWaitEvent(t, blockCache, txCall, types.EventStringAccCall(caller1ContractAddr)) // if exception == "" { t.Fatal("Expected exception") } @@ -828,8 +828,8 @@ func TestCreateAccountPermission(t *testing.T) { txCall, _ = types.NewCallTx(blockCache, user[0].PubKey, caller1ContractAddr, nil, 100, 10000, 100) txCall.Sign(chainID, user[0]) - // we need to subscribe to the Receive event to detect the exception - _, exception = execTxWaitEvent(t, blockCache, txCall, types.EventStringAccReceive(caller1ContractAddr)) // + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, txCall, types.EventStringAccCall(caller1ContractAddr)) // if exception != "" { t.Fatal("Unexpected exception", exception) } @@ -1048,7 +1048,7 @@ func TestSNativeTx(t *testing.T) { var ExceptionTimeOut = "timed out waiting for event" -// run ExecTx and wait for the Receive event on given addr +// run ExecTx and wait for the Call event on given addr // returns the msg data and an error/exception func execTxWaitEvent(t *testing.T, blockCache *BlockCache, tx types.Tx, eventid string) (interface{}, string) { evsw := events.NewEventSwitch() @@ -1109,8 +1109,8 @@ func testSNativeCALL(t *testing.T, expectPass bool, blockCache *BlockCache, doug addr = doug.Address tx, _ := types.NewCallTx(blockCache, user[0].PubKey, addr, data, 100, 10000, 100) tx.Sign(chainID, user[0]) - fmt.Println("subscribing to", types.EventStringAccReceive(snativeAddress)) - ev, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccReceive(snativeAddress)) + fmt.Println("subscribing to", types.EventStringAccCall(snativeAddress)) + ev, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(snativeAddress)) if exception == ExceptionTimeOut { t.Fatal("Timed out waiting for event") } diff --git a/types/events.go b/types/events.go index a9a3ff48..e3502a1a 100644 --- a/types/events.go +++ b/types/events.go @@ -14,8 +14,8 @@ func EventStringAccOutput(addr []byte) string { return fmt.Sprintf("Acc/%X/Output", addr) } -func EventStringAccReceive(addr []byte) string { - return fmt.Sprintf("Acc/%X/Receive", addr) +func EventStringAccCall(addr []byte) string { + return fmt.Sprintf("Acc/%X/Call", addr) } func EventStringLogEvent(addr []byte) string { diff --git a/vm/test/vm_test.go b/vm/test/vm_test.go index 417f6c9a..88b46df5 100644 --- a/vm/test/vm_test.go +++ b/vm/test/vm_test.go @@ -151,14 +151,14 @@ func TestSendCall(t *testing.T) { } } -// subscribes to an AccReceive, runs the vm, returns the exception +// subscribes to an AccCall, runs the vm, returns the exception func runVMWaitEvents(t *testing.T, ourVm *VM, caller, callee *Account, subscribeAddr, contractCode []byte, gas int64) string { // we need to catch the event from the CALL to check for exceptions evsw := events.NewEventSwitch() evsw.Start() ch := make(chan interface{}) fmt.Printf("subscribe to %x\n", subscribeAddr) - evsw.AddListenerForEvent("test", types.EventStringAccReceive(subscribeAddr), func(msg interface{}) { + evsw.AddListenerForEvent("test", types.EventStringAccCall(subscribeAddr), func(msg interface{}) { ch <- msg }) evc := events.NewEventCache(evsw) diff --git a/vm/vm.go b/vm/vm.go index 64420699..8c16c5b7 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -95,10 +95,10 @@ func HasPermission(appState AppState, acc *Account, perm ptypes.PermFlag) bool { return v } -func (vm *VM) fireEvent(exception *string, output *[]byte, caller, callee *Account, input []byte, value int64, gas *int64) { +func (vm *VM) fireCallEvent(exception *string, output *[]byte, caller, callee *Account, input []byte, value int64, gas *int64) { // fire the post call event (including exception if applicable) if vm.evc != nil { - vm.evc.FireEvent(types.EventStringAccReceive(callee.Address.Postfix(20)), types.EventMsgCall{ + vm.evc.FireEvent(types.EventStringAccCall(callee.Address.Postfix(20)), types.EventMsgCall{ &types.CallData{caller.Address.Postfix(20), callee.Address.Postfix(20), input, value, *gas}, vm.origin.Postfix(20), vm.txid, @@ -116,7 +116,7 @@ func (vm *VM) Call(caller, callee *Account, code, input []byte, value int64, gas exception := new(string) // fire the post call event (including exception if applicable) - defer vm.fireEvent(exception, &output, caller, callee, input, value, gas) + defer vm.fireCallEvent(exception, &output, caller, callee, input, value, gas) if err = transfer(caller, callee, value); err != nil { *exception = err.Error() @@ -754,12 +754,12 @@ func (vm *VM) call(caller, callee *Account, code, input []byte, value int64, gas // Native contract ret, err = nativeContract(vm.appState, callee, args, &gasLimit) - // for now we fire the Receive event. maybe later we'll fire more particulars + // for now we fire the Call event. maybe later we'll fire more particulars var exception string if err != nil { exception = err.Error() } - vm.fireEvent(&exception, &ret, callee, &Account{Address: addr}, args, value, gas) + vm.fireCallEvent(&exception, &ret, callee, &Account{Address: addr}, args, value, gas) } else { // EVM contract if ok = useGas(gas, GasGetAccount); !ok {