MCPcopy Create free account
hub / github.com/chain/Core / TestCreateControlProgram

Function TestCreateControlProgram

core/account/accounts_test.go:72–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestCreateControlProgram(t *testing.T) {
73 // use pgtest.NewDB for deterministic postgres sequences
74 _, db := pgtest.NewDB(t, pgtest.SchemaPath)
75 m := NewManager(db, prottest.NewChain(t), nil)
76 ctx := context.Background()
77
78 account, err := m.Create(ctx, []chainkd.XPub{testutil.TestXPub}, 1, "", nil, "")
79 if err != nil {
80 testutil.FatalErr(t, err)
81 }
82
83 got, err := m.CreateControlProgram(ctx, account.ID, false, time.Now().Add(5*time.Minute))
84 if err != nil {
85 testutil.FatalErr(t, err)
86 }
87
88 want, err := vm.Assemble("DUP TOALTSTACK SHA3 0x6dbfeed3d0cffddbda105bfe320072b067304af099c9cff0251d5446412e524a 1 1 CHECKMULTISIG VERIFY FROMALTSTACK 0 CHECKPREDICATE")
89 if err != nil {
90 testutil.FatalErr(t, err)
91 }
92
93 if !bytes.Equal(got, want) {
94 t.Errorf("got control program = %x want %x", got, want)
95 }
96}
97
98func (m *Manager) createTestAccount(ctx context.Context, t testing.TB, alias string, tags map[string]interface{}) *Account {
99 account, err := m.Create(ctx, []chainkd.XPub{testutil.TestXPub}, 1, alias, tags, "")

Callers

nothing calls this directly

Calls 5

CreateMethod · 0.95
CreateControlProgramMethod · 0.95
NewManagerFunction · 0.85
AddMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected