forked from solana-foundation/solana-go
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathregistry_test.go
More file actions
27 lines (20 loc) · 779 Bytes
/
registry_test.go
File metadata and controls
27 lines (20 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package solana
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestRegisterInstructionDecoder(t *testing.T) {
decoder := func(instructionAccounts []*AccountMeta, data []byte) (any, error) {
return nil, nil
}
decoderAnother := func(instructionAccounts []*AccountMeta, data []byte) (any, error) {
return nil, nil
}
// First registration succeeds.
require.NoError(t, RegisterInstructionDecoder(BPFLoaderProgramID, decoder))
// Re-registering the same decoder is a no-op.
require.NoError(t, RegisterInstructionDecoder(BPFLoaderProgramID, decoder))
// Registering a different decoder for the same programID returns an error.
assert.Error(t, RegisterInstructionDecoder(BPFLoaderProgramID, decoderAnother))
}