62 lines
1.8 KiB
Go
62 lines
1.8 KiB
Go
|
|
package shreder
|
||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/hex"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestDFlowDecodedSwapParams(t *testing.T) {
|
||
|
|
tests := []struct {
|
||
|
|
name string
|
||
|
|
hexData string
|
||
|
|
}{
|
||
|
|
{
|
||
|
|
name: "DFlow swap Test 0",
|
||
|
|
hexData: "f8c69e91e17587c806000000256cb411cd4dcea8c073833936254cc3a7a6f1bc3e1106af1fceaed1bf6d75184d8149476a66d1f0d4c23c177e81d73b8b11297c7f7d8a8d6e339939647915d8096cfcdd170000000093000000300300000000000000000000000000000000000000a84325c4000000002d0decfc36e0bc09000001197bcde00df80000000180130edffead0800000081711ebdc4000000002c013200",
|
||
|
|
},
|
||
|
|
}
|
||
|
|
for _, tt := range tests {
|
||
|
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
|
instrData, err := hex.DecodeString(tt.hexData)
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("failed to decode hex string: %v", err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
//t.Logf("raw bytes: %x", instrData[8:])
|
||
|
|
args, err := decodeSwapParams(instrData[8:])
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("failed to decode dflow arguments: %v", err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
t.Logf("decoded args: %+v", args)
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestDFlowV2DecodedSwapParams(t *testing.T) {
|
||
|
|
tests := []struct {
|
||
|
|
name string
|
||
|
|
hexData string
|
||
|
|
}{
|
||
|
|
{
|
||
|
|
name: "DFlow swap 2 Test 0",
|
||
|
|
hexData: "414b3f4ceb5b5b880300000025427ee16eed91684faaad4a3f161acd31d92bbc3d1ba0e2ebdb4678448fd5a7aeade9c8b38e8755e811f3373a0056cd5647e4cc3510135f98e97cb03c046ade049d08de17000000007800000023f50a0000000000002e1bfe04000000000001c3e13700000000003601000005",
|
||
|
|
},
|
||
|
|
}
|
||
|
|
for _, tt := range tests {
|
||
|
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
|
instrData, err := hex.DecodeString(tt.hexData)
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("failed to decode hex string: %v", err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
args, err := decodeSwap2Params(instrData[8:])
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("failed to decode dflow arguments: %v", err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
t.Logf("decoded args: %+v", args)
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|