Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tholonious committed Jan 26, 2024
1 parent daf70ea commit e93d742
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 10 additions & 4 deletions lib/pos_block_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ func (pbp *PosBlockProducer) createBlockWithoutHeader(
blockRewardOutput := &DeSoOutput{}
blockRewardOutput.AmountNanos = math.MaxUint64
blockRewardOutput.PublicKey = pbp.proposerPublicKey.ToBytes()
blockRewardTxn.PublicKey = pbp.proposerPublicKey.ToBytes()
blockRewardTxn.TxOutputs = append(blockRewardTxn.TxOutputs, blockRewardOutput)
blockRewardTxn.TxnMeta = &BlockRewardMetadataa{}
blockRewardTxnSizeBytes, err := blockRewardTxn.ToBytes(true)
Expand All @@ -143,9 +142,16 @@ func (pbp *PosBlockProducer) createBlockWithoutHeader(

// getBlockTransactions is used to retrieve fee-time ordered transactions from the mempool.
func (pbp *PosBlockProducer) getBlockTransactions(
latestBlockView *UtxoView, newBlockHeight uint64, newBlockTimestampNanoSecs uint64,
maxBlockSizeBytes uint64) (_txns []*MsgDeSoTxn, _txnConnectStatusByIndex *bitset.Bitset,
_maxUtilityFee uint64, _err error) {
latestBlockView *UtxoView,
newBlockHeight uint64,
newBlockTimestampNanoSecs uint64,
maxBlockSizeBytes uint64,
) (
_txns []*MsgDeSoTxn,
_txnConnectStatusByIndex *bitset.Bitset,
_maxUtilityFee uint64,
_err error,
) {
// Get Fee-Time ordered transactions from the mempool
feeTimeTxns := pbp.mp.GetTransactions()

Expand Down
4 changes: 3 additions & 1 deletion lib/pos_block_producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func TestCreateBlockTemplate(t *testing.T) {
require.Equal(blockTemplate.Header.ProposerPublicKey, m0Pk)
require.Equal(blockTemplate.Header.ProposerVotingPublicKey, pub)
require.True(blockTemplate.Header.ProposerRandomSeedSignature.Eq(seedSignature))
require.Equal(blockTemplate.Header.TxnConnectStatusByIndexHash, HashBitset(blockTemplate.TxnConnectStatusByIndex))
}

func TestCreateBlockWithoutHeader(t *testing.T) {
Expand All @@ -87,6 +88,7 @@ func TestCreateBlockWithoutHeader(t *testing.T) {
feeMax := uint64(2000)
passingTransactions := 50
m0PubBytes, _, _ := Base58CheckDecode(m0Pub)
blsPubKey, _ := _generateValidatorVotingPublicKeyAndSignature(t)
params, db := _posTestBlockchainSetupWithBalances(t, 200000, 200000)
params.ForkHeights.ProofOfStake2ConsensusCutoverBlockHeight = 1
maxMempoolPosSizeBytes := uint64(3000000000)
Expand Down Expand Up @@ -115,7 +117,7 @@ func TestCreateBlockWithoutHeader(t *testing.T) {
_wrappedPosMempoolAddTransaction(t, mempool, txn)
}

pbp := NewPosBlockProducer(mempool, params, nil, nil)
pbp := NewPosBlockProducer(mempool, params, NewPublicKey(m0PubBytes), blsPubKey)
txns, txnConnectStatus, maxUtilityFee, err := pbp.getBlockTransactions(
latestBlockView, 3, 0, 50000)
require.NoError(err)
Expand Down

0 comments on commit e93d742

Please sign in to comment.