Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewFallback TC bug #22049

Closed
yoomee1313 opened this issue Dec 21, 2020 · 0 comments
Closed

NewFallback TC bug #22049

yoomee1313 opened this issue Dec 21, 2020 · 0 comments
Labels

Comments

@yoomee1313
Copy link
Contributor

System information

Geth version: v1.9.21
OS & Version: OSX

Expected behaviour

  • Fallback function of NewFallbacks 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")
	}
}

Backtrace

gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this issue Jan 7, 2025
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this issue Jan 8, 2025
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this issue Jan 9, 2025
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this issue Jan 10, 2025
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this issue Jan 10, 2025
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this issue Jan 10, 2025
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this issue Jan 10, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this issue Jan 14, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this issue Jan 16, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this issue Jan 17, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this issue Jan 22, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this issue Jan 22, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this issue Jan 23, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this issue Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant