MCPcopy Create free account
hub / github.com/chain/txvm / TestNewTx

Function TestNewTx

protocol/bc/tx_test.go:20–207  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18var zeroes32 [32]byte
19
20func TestNewTx(t *testing.T) {
21 cases := []struct {
22 name string
23 asm string
24 want *Tx
25 }{
26 {
27 name: "simple payment",
28 asm: txvmtest.SimplePayment,
29 want: &Tx{
30 RawTx: RawTx{
31 Version: 3,
32 Runlimit: 100000,
33 },
34 Finalized: true,
35 ID: mustDecodeHash("c10da3fb9bed06674f9e247c5fff60c712c7d47881f3843a0c75d91544ed76b8"),
36 Contracts: []Contract{
37 {InputType, mustDecodeHash("7229e653bd7c21efae174d7d3e8087ea8e5e1d074adc59a1dfbd88c484ead9ea")},
38 {OutputType, mustDecodeHash("333b102f5eebf7450cced735b1a2518f98f706b52828197d6bd70229e2e669f5")},
39 },
40 Anchor: mustDecodeHex("a4eb3b92e93f5889d7dd213530ee968c4f602ca45b3fc34d0936417d6daa59b0"),
41 Inputs: []Input{{
42 ID: mustDecodeHash("7229e653bd7c21efae174d7d3e8087ea8e5e1d074adc59a1dfbd88c484ead9ea"),
43 Seed: mustDecodeHash("636f6e7472616374736565640000000000000000000000000000000000000000"),
44 Stack: []txvm.Data{
45 txvm.Tuple{txvm.Bytes{txvm.BytesCode}, txvm.Bytes(mustDecodeHex("4a771e03af3f5705ec280ac8761d568776fb2b650da9067d3f3ef7010b588d41"))},
46 txvm.Tuple{
47 txvm.Bytes{txvm.ValueCode},
48 txvm.Int(10),
49 txvm.Bytes(mustDecodeHex("d073785d7dffc98c69ef62bbc6c8efde78a3286a848f570f8028695048a8f62d")),
50 txvm.Bytes([]byte("anchor")),
51 },
52 },
53 Program: []byte{op.Put, op.MinPushdata + 7, op.TxID, op.MinSmallInt + 1, op.Roll, op.Get, op.MinSmallInt + 0, op.CheckSig, op.Verify, op.Yield},
54 LogPos: 0,
55 }},
56 Outputs: []Output{{
57 ID: mustDecodeHash("333b102f5eebf7450cced735b1a2518f98f706b52828197d6bd70229e2e669f5"),
58 Seed: mustDecodeHash("30b12caddb68c2da018ff46f7d358aa8b8ca9fdfd05c04478ccd5c9599583ad0"),
59 Stack: []txvm.Data{
60 txvm.Tuple{txvm.Bytes{txvm.BytesCode}, txvm.Bytes(mustDecodeHex("1111111111111111111111111111111111111111111111111111111111111111"))},
61 txvm.Tuple{
62 txvm.Bytes{txvm.ValueCode},
63 txvm.Int(10),
64 txvm.Bytes(mustDecodeHex("d073785d7dffc98c69ef62bbc6c8efde78a3286a848f570f8028695048a8f62d")),
65 txvm.Bytes(mustDecodeHex("25703d95c689c0d5619fa7c011fd5df200e0e1ab46623ebeee36c75c1ef16241")),
66 },
67 },
68 Program: []byte{op.Put, op.MinPushdata + 7, op.TxID, op.MinSmallInt + 1, op.Roll, op.Get, op.MinSmallInt + 0, op.CheckSig, op.Verify, op.Yield},
69 LogPos: 1,
70 }},
71 },
72 },
73 {
74 name: "issuance",
75 asm: txvmtest.Issuance,
76 want: &Tx{
77 RawTx: RawTx{

Callers

nothing calls this directly

Calls 6

BytesTypeAlias · 0.92
IntTypeAlias · 0.92
AssembleFunction · 0.92
NewTxFunction · 0.85
mustDecodeHashFunction · 0.70
mustDecodeHexFunction · 0.70

Tested by

no test coverage detected