Skip to content

Commit eb5a500

Browse files
committed
Add tests for nft detection
1 parent a0d6497 commit eb5a500

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

mock/nft_mock_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package mock
2+
3+
import (
4+
"math/big"
5+
"testing"
6+
7+
"github.com/ethereum/go-ethereum/common"
8+
"github.com/ethereum/go-ethereum/core/types"
9+
"github.com/stretchr/testify/assert"
10+
)
11+
12+
func TestMockNFTDetector(t *testing.T) {
13+
detector := NewMockNFTDetector()
14+
15+
t.Run("Known contract", func(t *testing.T) {
16+
detector.Reset()
17+
address := common.HexToAddress("0xBAYC")
18+
detector.AddKnownContract(address)
19+
20+
tx := types.NewTransaction(
21+
0,
22+
address, // Remove & operator, use Address directly
23+
big.NewInt(0),
24+
21000,
25+
big.NewInt(1),
26+
nil,
27+
)
28+
result := detector.IsNFTTransaction(tx)
29+
assert.True(t, result)
30+
})
31+
}

0 commit comments

Comments
 (0)