package paraswap import ( "testing" "github.com/stretchr/testify/assert" ) func TestUnmarshallBuildTransaction(t *testing.T) { tx := Transaction{ From: "0xbe0eb53f46cd790cd13851d5eff43d12404d33e8", To: "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57", Value: "10000000000000000", Data: "0xf566103400000000000000000000000075e48c954594d64ef9613aeef97ad85370f13807b2b53dca60cae1d1f93f64d80703b888689f28b63c483459183f2f4271fa0308000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000001c2354900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7", GasPrice: "47490307239", Gas: "197142", ChainID: 1, } data := []byte(`{ "from": "0xbe0eb53f46cd790cd13851d5eff43d12404d33e8", "to": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57", "value": "10000000000000000", "data": "0xf566103400000000000000000000000075e48c954594d64ef9613aeef97ad85370f13807b2b53dca60cae1d1f93f64d80703b888689f28b63c483459183f2f4271fa0308000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000001c2354900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7", "gasPrice": "47490307239", "gas": "197142", "chainId": 1 }`) receivedTx, err := handleBuildTransactionResponse(data) assert.NoError(t, err) assert.Equal(t, tx, receivedTx) } func TestForErrorOnBuildingTransaction(t *testing.T) { data := []byte(`{ "error": "Invalid tokens" }`) _, err := handleBuildTransactionResponse(data) assert.Error(t, err) }