summaryrefslogtreecommitdiff
path: root/data/pools/transactionPool_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'data/pools/transactionPool_test.go')
-rw-r--r--data/pools/transactionPool_test.go44
1 files changed, 13 insertions, 31 deletions
diff --git a/data/pools/transactionPool_test.go b/data/pools/transactionPool_test.go
index f9ddb4b00..4e65333b6 100644
--- a/data/pools/transactionPool_test.go
+++ b/data/pools/transactionPool_test.go
@@ -29,7 +29,6 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/bookkeeping"
- "github.com/algorand/go-algorand/data/pooldata"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/ledger"
@@ -56,15 +55,6 @@ type TestingT interface {
var minBalance = config.Consensus[protocol.ConsensusCurrentVersion].MinBalance
-// RememberOne stores the provided transaction.
-// Precondition: Only RememberOne() properly-signed and well-formed transactions (i.e., ensure t.WellFormed())
-func (pool *TransactionPool) RememberOne(t transactions.SignedTxn) error {
- txgroup := pooldata.SignedTxGroup{
- Transactions: []transactions.SignedTxn{t},
- }
- return pool.Remember(txgroup)
-}
-
func mockLedger(t TestingT, initAccounts map[basics.Address]basics.AccountData, proto protocol.ConsensusVersion) *ledger.Ledger {
var hash crypto.Digest
crypto.RandBytes(hash[:])
@@ -95,9 +85,9 @@ func mockLedger(t TestingT, initAccounts map[basics.Address]basics.AccountData,
fn := fmt.Sprintf("/tmp/%s.%d.sqlite3", t.Name(), crypto.RandUint64())
const inMem = true
- genesisInitState := ledger.InitState{Block: initBlock, Accounts: initAccounts, GenesisHash: hash}
+ genesisInitState := ledgercore.InitState{Block: initBlock, Accounts: initAccounts, GenesisHash: hash}
cfg := config.GetDefaultLocal()
- cfg.Archival = false
+ cfg.Archival = true
l, err := ledger.OpenLedger(logging.Base(), fn, true, genesisInitState, cfg)
require.NoError(t, err)
return l
@@ -111,7 +101,7 @@ func makeMockLedgerFuture(t TestingT, initAccounts map[basics.Address]basics.Acc
return mockLedger(t, initAccounts, protocol.ConsensusFuture)
}
-func newBlockEvaluator(t TestingT, l *ledger.Ledger) *ledger.BlockEvaluator {
+func newBlockEvaluator(t TestingT, l *ledger.Ledger) BlockEvaluator {
latest := l.Latest()
prev, err := l.BlockHdr(latest)
require.NoError(t, err)
@@ -568,7 +558,7 @@ func TestRememberForget(t *testing.T) {
}
}
- pending, _ := transactionPool.PendingTxGroups()
+ pending := transactionPool.PendingTxGroups()
numberOfTxns := numOfAccounts*numOfAccounts - numOfAccounts
require.Len(t, pending, numberOfTxns)
@@ -579,7 +569,7 @@ func TestRememberForget(t *testing.T) {
require.NoError(t, err)
transactionPool.OnNewBlock(blk.Block(), ledgercore.StateDelta{})
- pending, _ = transactionPool.PendingTxGroups()
+ pending = transactionPool.PendingTxGroups()
require.Len(t, pending, 0)
}
@@ -644,7 +634,7 @@ func TestCleanUp(t *testing.T) {
transactionPool.OnNewBlock(blk.Block(), ledgercore.StateDelta{})
}
- pending, _ := transactionPool.PendingTxGroups()
+ pending := transactionPool.PendingTxGroups()
require.Zero(t, len(pending))
require.Zero(t, transactionPool.NumExpired(4))
require.Equal(t, issuedTransactions, transactionPool.NumExpired(5))
@@ -718,7 +708,7 @@ func TestFixOverflowOnNewBlock(t *testing.T) {
}
}
}
- pending, _ := transactionPool.PendingTxGroups()
+ pending := transactionPool.PendingTxGroups()
require.Len(t, pending, savedTransactions)
secret := keypair()
@@ -754,7 +744,7 @@ func TestFixOverflowOnNewBlock(t *testing.T) {
transactionPool.OnNewBlock(block.Block(), ledgercore.StateDelta{})
- pending, _ = transactionPool.PendingTxGroups()
+ pending = transactionPool.PendingTxGroups()
// only one transaction is missing
require.Len(t, pending, savedTransactions-1)
}
@@ -862,15 +852,7 @@ func TestRemove(t *testing.T) {
}
signedTx := tx.Sign(secrets[0])
require.NoError(t, transactionPool.RememberOne(signedTx))
- pendingTxGroups, _ := transactionPool.PendingTxGroups()
- require.Equal(t, []pooldata.SignedTxGroup{
- {
- Transactions: []transactions.SignedTxn{signedTx},
- GroupCounter: 1,
- GroupTransactionID: (pooldata.SignedTxnSlice{signedTx}).ID(),
- EncodedLength: len(signedTx.MarshalMsg([]byte{})),
- },
- }, pendingTxGroups)
+ require.Equal(t, transactionPool.PendingTxGroups(), [][]transactions.SignedTxn{{signedTx}})
}
func TestLogicSigOK(t *testing.T) {
@@ -1185,7 +1167,7 @@ func BenchmarkTransactionPoolSteadyState(b *testing.B) {
for len(ledgerTxnQueue) > 0 {
stx := ledgerTxnQueue[0]
err := eval.Transaction(stx, transactions.ApplyData{})
- if err == ledger.ErrNoSpace {
+ if err == ledgercore.ErrNoSpace {
break
}
require.NoError(b, err)
@@ -1256,7 +1238,7 @@ func TestTxPoolSizeLimits(t *testing.T) {
}
for groupSize := config.Consensus[protocol.ConsensusCurrentVersion].MaxTxGroupSize; groupSize > 0; groupSize-- {
- var txgroup pooldata.SignedTxGroup
+ var txgroup []transactions.SignedTxn
// fill the transaction group with groupSize transactions.
for i := 0; i < groupSize; i++ {
tx := transactions.Transaction{
@@ -1275,7 +1257,7 @@ func TestTxPoolSizeLimits(t *testing.T) {
},
}
signedTx := tx.Sign(secrets[0])
- txgroup.Transactions = append(txgroup.Transactions, signedTx)
+ txgroup = append(txgroup, signedTx)
uniqueTxID++
}
@@ -1285,7 +1267,7 @@ func TestTxPoolSizeLimits(t *testing.T) {
if groupSize > 1 {
// add a single transaction and ensure we succeed
// consume the transaction of allowed limit
- require.NoError(t, transactionPool.RememberOne(txgroup.Transactions[0]))
+ require.NoError(t, transactionPool.RememberOne(txgroup[0]))
}
}
}