pump and pump swap errTx parser

This commit is contained in:
thloyi
2026-02-26 16:11:34 +08:00
parent 972ddc7960
commit b0d4342fa2
12 changed files with 704 additions and 722 deletions

47
error_test.go Normal file
View File

@@ -0,0 +1,47 @@
package pump_parser
import (
"encoding/base64"
"testing"
)
func TestDecodeTransactionError(t *testing.T) {
var testCases = []struct {
name string
data string
}{
{
name: "ComputationalBudgetExceeded",
data: "CAAAAAMlAAAA",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
bytesData, err := base64.StdEncoding.DecodeString(tc.data)
if err != nil {
t.Fatalf("Failed to decode base64 data for %s: %v", tc.name, err)
return
}
te, err := DecodeTransactionError(bytesData)
if err != nil {
t.Errorf("Decoded error for %s: %v", tc.name, err)
return
}
if te.Variant != InstructionError {
t.Errorf("Expected Variant to be InstructionError for %s, got %d", tc.name, te.Variant)
return
}
errName, err := te.GetInstructionError()
if err != nil {
t.Errorf("Failed to get instruction error for %s: %v", tc.name, err)
return
}
if errName.Variant != ComputationalBudgetExceeded {
t.Errorf("Expected instruction error variant to be Custom for %s, got %d", tc.name, errName.Variant)
return
}
})
}
}