github.com/0xsequence/ethkit@v1.25.0/ethcoder/events_test.go (about)

     1  package ethcoder_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/0xsequence/ethkit/ethcoder"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func TestEventTopicHash(t *testing.T) {
    11  	in := []struct {
    12  		event string
    13  	}{
    14  		{"Transfer(address indexed from, address indexed to, uint256 value)"},
    15  		{"Transfer(address from, address indexed to, uint256 value)"},
    16  		{"Transfer(address, address , uint256 )"},
    17  	}
    18  
    19  	for _, x := range in {
    20  		topicHash, err := ethcoder.EventTopicHash(x.event)
    21  		require.NoError(t, err)
    22  		require.Equal(t, "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", topicHash.String())
    23  	}
    24  }