pump and pump swap errTx parser
This commit is contained in:
47
error_test.go
Normal file
47
error_test.go
Normal 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
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user