diff --git a/mock/nft_mock.go b/mock/nft_mock.go index cda4033..b005ba0 100644 --- a/mock/nft_mock.go +++ b/mock/nft_mock.go @@ -40,13 +40,15 @@ func (m *MockNFTDetector) IsNFTTransaction(tx *types.Transaction) bool { return m.IsNFTTransactionFunc(tx) } - // Default implementation using known contracts if tx.To() == nil { return false } - isContract, exists := m.knownContracts.Load(*tx.To()) - return exists && isContract.(bool) + if val, exists := m.knownContracts.Load(*tx.To()); exists { + return val.(bool) + } + + return false } // Helper methods for testing diff --git a/mock/nft_mock_test.go b/mock/nft_mock_test.go index 90b9f78..7267f8b 100644 --- a/mock/nft_mock_test.go +++ b/mock/nft_mock_test.go @@ -17,15 +17,27 @@ func TestMockNFTDetector(t *testing.T) { address := common.HexToAddress("0xBAYC") detector.AddKnownContract(address) + // Create transaction to the known contract address tx := types.NewTransaction( 0, - address, // Remove & operator, use Address directly + address, big.NewInt(0), 21000, big.NewInt(1), nil, ) + + // Add debug assertions + toAddr := tx.To() + if toAddr == nil { + t.Fatal("Transaction To address is nil") + } + + // Verify the addresses match + assert.Equal(t, address, *toAddr, "Transaction address should match known contract") + + // Check if transaction is detected as NFT result := detector.IsNFTTransaction(tx) - assert.True(t, result) + assert.True(t, result, "Transaction to known NFT contract address should return true") }) }