Refactor tx generator methods and add more comments

pull/17/head
Rongjian Lan 6 years ago
parent 8cee77e82e
commit c8627fa32a
  1. 2
      benchmark_main.go
  2. 8
      node/node.go
  3. 2
      node/node_test.go

@ -107,7 +107,7 @@ func main() {
consensus.OnConsensusDone = node.PostConsensusProcessing
// Temporary testing code, to be removed.
node.AddMoreFakeTransactions(10000)
node.AddTestingAddresses(10000)
if consensus.IsLeader {
// Let consensus run

@ -86,10 +86,10 @@ func (node *Node) String() string {
return node.Consensus.String()
}
// [Testing code] Should be deleted for production
// Create in genesis block numTxs transactions which assign 1000 token to each address in [1 - numTxs]
func (node *Node) AddMoreFakeTransactions(numTxs int) {
txs := make([]*blockchain.Transaction, numTxs)
// [Testing code] Should be deleted after production
// Creates in genesis block numAddress transactions which assign 1000 token to each address in [0 - numAddress)
func (node *Node) AddTestingAddresses(numAddress int) {
txs := make([]*blockchain.Transaction, numAddress)
for i := range txs {
txs[i] = blockchain.NewCoinbaseTX(strconv.Itoa(i), "", node.Consensus.ShardID)
}

@ -39,7 +39,7 @@ func TestCountNumTransactionsInBlockchain(test *testing.T) {
consensus := consensus.NewConsensus("1", "2", "0", []p2p.Peer{leader, validator}, leader)
node := NewNode(&consensus)
node.AddMoreFakeTransactions(1000)
node.AddTestingAddresses(1000)
if node.countNumTransactionsInBlockchain() != 1001 {
test.Error("Count of transactions in the blockchain is incorrect")
}

Loading…
Cancel
Save