add test to ensure that go-loom WithdrawalHash implementation is equivalent to loom-js createWithdrawalHash implementation
data taken from experiment on testnet
@@ -9,9 +9,27 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
+ tgtypes "github.com/loomnetwork/go-loom/builtin/types/transfer_gateway"
"github.com/stretchr/testify/assert"
+ "math/big"
)
+func TestWithdrawalHash(t *testing.T) {
+ t.Logf("Testing withdrawal hash")
+ hash := WithdrawalHash(
+ common.HexToAddress("0x8b7495748a4aa54d98660cb51f6fa7f244568b9d"), // withdrawer
+ common.HexToAddress("0xE681fc277ef3Eed61f0d48FB87Aa2EEe9F67aBB4"), // token addr
+ common.HexToAddress("0x5D442Ef71427Fb0F57D63605F6FAf34cA8e78341"), // gateway addr
+ tgtypes.TransferGatewayTokenKind_ERC20,
+ big.NewInt(0),
+ big.NewInt(2000000000000000000),
+ big.NewInt(0),
+ true,
+ )
+ assert.Equal(t, hex.EncodeToString(hash), "ed49f376605734945e3b1ddd0ec6341a76fdcda5b47138a4afc6d4b9ea04ab05")
+
+}
+
func TestParseSigWithoutMode(t *testing.T) {
t.Logf("Testing parse sigs")
sigs, _ := hex.DecodeString("cd7f07b4f35d2d2dee86bde44d765aef81673745aab5d5aaf4422dc73938237d2cbc5105bc0ceddbf4037b62003159903d35b834496a622ba4d9117008c164401c")
