MCPcopy Create free account
hub / github.com/DNAProject/DNA / TestTxPool

Function TestTxPool

txnpool/common/transaction_pool_test.go:50–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestTxPool(t *testing.T) {
51 txPool := &TXPool{}
52 txPool.Init()
53
54 txEntry := &TXEntry{
55 Tx: txn,
56 Attrs: []*TXAttr{},
57 }
58
59 ret := txPool.AddTxList(txEntry)
60 if ret == false {
61 t.Error("Failed to add tx to the pool")
62 return
63 }
64
65 ret = txPool.AddTxList(txEntry)
66 if ret == true {
67 t.Error("Failed to add tx to the pool")
68 return
69 }
70
71 txList, oldTxList := txPool.GetTxPool(true, 0)
72 for _, v := range txList {
73 assert.NotNil(t, v)
74 }
75
76 for _, v := range oldTxList {
77 assert.NotNil(t, v)
78 }
79
80 entry := txPool.GetTransaction(txn.Hash())
81 if entry == nil {
82 t.Error("Failed to get the transaction")
83 return
84 }
85
86 assert.Equal(t, txn.Hash(), entry.Hash())
87
88 status := txPool.GetTxStatus(txn.Hash())
89 if status == nil {
90 t.Error("failed to get the status")
91 return
92 }
93
94 assert.Equal(t, txn.Hash(), status.Hash)
95
96 count := txPool.GetTransactionCount()
97 assert.Equal(t, count, 1)
98
99 err := txPool.CleanTransactionList([]*types.Transaction{txn})
100 if err != nil {
101 t.Error("Failed to clean transaction list")
102 return
103 }
104}

Callers

nothing calls this directly

Calls 9

InitMethod · 0.95
AddTxListMethod · 0.95
GetTxPoolMethod · 0.95
GetTransactionMethod · 0.95
GetTxStatusMethod · 0.95
GetTransactionCountMethod · 0.95
CleanTransactionListMethod · 0.95
ErrorMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected