fix axios parser

This commit is contained in:
thloyi
2026-01-07 13:16:22 +08:00
parent 122d474524
commit 214d9e984e
3 changed files with 92 additions and 31 deletions

View File

@@ -0,0 +1,56 @@
package shreder
import (
"encoding/hex"
"testing"
"github.com/near/borsh-go"
)
func TestDecodeAxiomArgs(t *testing.T) {
tests := []struct {
name string
hexData string
}{
{
name: "pump amm sell Test 0",
hexData: "00686f08bb1b0000007eb4ac020000000001020200183c",
},
{
name: "pump amm buy Test 1",
hexData: "00c09ee6050000000001c94d882600000000020200323c",
},
{
name: "pump buy Test 2",
hexData: "00d8d3bc0000000000bb7c53f009000000000104185a",
},
{
name: "pump sell Test 3",
hexData: "009bbf69ec08080000830bc61200000000010103a000",
},
{
name: "pump swap sell Test 4",
hexData: "00c98ea7588b0000009adf3b010000000001020200283c",
},
{
name: "pump swap sell Test 5",
hexData: "00d3727f9301000000f9a50b0100000000010202001e00",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
data, err := hex.DecodeString(tt.hexData)
if err != nil {
t.Fatalf("failed to decode hex string: %v", err)
return
}
var args flasArgs
if err := borsh.Deserialize(&args, data[1:]); err != nil {
t.Fatalf("failed to decode Axiom args: %v", err)
return
}
t.Logf("Decoded Axiom Args: %+v", args)
})
}
}