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

Function TestBadMaxNonceWindow

protocol/tx_test.go:11–37  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestBadMaxNonceWindow(t *testing.T) {
12 ctx := context.Background()
13 c, b1 := newTestChain(t, time.Now())
14 c.bb.MaxNonceWindow = time.Second
15
16 tx := &bc.Tx{
17 Nonces: []bc.Nonce{{ExpMS: bc.Millis(time.Now().Add(5 * time.Second))}},
18 Finalized: true,
19 }
20
21 got, _, err := c.GenerateBlock(ctx, b1.TimestampMs+1, []*bc.CommitmentsTx{bc.NewCommitmentsTx(tx)})
22 if err != nil {
23 t.Fatal(err)
24 }
25 if len(got.Transactions) != 0 {
26 t.Error("expected issuance past max issuance window to be rejected")
27 }
28
29 c.bb.MaxNonceWindow = 0
30 got, _, err = c.GenerateBlock(ctx, b1.TimestampMs+1, []*bc.CommitmentsTx{bc.NewCommitmentsTx(tx)})
31 if err != nil {
32 t.Fatal(err)
33 }
34 if len(got.Transactions) != 1 {
35 t.Error("expected 0 max issuance to be ignored")
36 }
37}

Callers

nothing calls this directly

Calls 6

MillisFunction · 0.92
NewCommitmentsTxFunction · 0.92
newTestChainFunction · 0.85
GenerateBlockMethod · 0.80
ErrorMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected