Closed
Description
System information
Geth version: v1.9.21
OS & Version: OSX
Expected behaviour
Fallback
function ofNewFallbacks
solidity code fails due to out-of-gas.- Since it fails, it should not get an event, and it should catch an error.
Actual behaviour
- It cannot catch the error.
Steps to reproduce the behaviour
tc location: accounts/abi/bind/bind_test.go
tc: NewFallback
(line 1597 ~ line 1687)
-> bool gotEvent
is set to true
at point1, and it is not initialized. Then, fallback tx is failed, and event is not arrived.
-> At point2, the gotEvent is true even fallback tx is failed. So, it cannot catch the error.
-> If gotEvent = false
code is inserted just before point3, it would catch an error.
-> Also, it would be nice if solidity code is fixed. calldatacopy(data, 0, calldatasize())
is not working. For me, below fallback function passes the NewFallback tc.
fallback() external {
emit Fallback(data);
}
func TestNewFallbacks(t *testing.T) {
// skip code...
// Test receive function
opts.Value = big.NewInt(100)
c.Receive(opts)
sim.Commit()
var gotEvent bool
iter, _ := c.FilterReceived(nil)
defer iter.Close()
for iter.Next() {
// skip code...
gotEvent = true //--------------------------------------------point1
break
}
if !gotEvent {
t.Fatal("Expect to receive event emitted by receive")
}
// Test fallback function
opts.Value = nil // ------------------------------------------------point3
calldata := []byte{0x01, 0x02, 0x03}
fmt.Println("Fallback start")
c.Fallback(opts, calldata)
sim.Commit()
iter2, _ := c.FilterFallback(nil)
defer iter2.Close()
for iter2.Next() {
if !bytes.Equal(iter2.Event.Data, calldata) {
t.Fatal("calldata mismatch")
}
gotEvent = true
break
}
if !gotEvent { //--------------------------------------------------point2
t.Fatal("Expect to receive event emitted by fallback")
}
}