48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
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
|
|
}
|
|
})
|
|
}
|
|
}
|