mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-24 23:46:17 +00:00
fix Panic In ProcessOrderPending Leads To Chain Halt (#392)
Co-authored-by: Liam Lai <liamlai@Liams-Laptop.local>
This commit is contained in:
parent
a76c885774
commit
81ff6421d0
2 changed files with 34 additions and 0 deletions
|
|
@ -304,6 +304,9 @@ func NewOrderTransactionByNonce(signer OrderSigner, txs map[common.Address]Order
|
|||
// Initialize a price based heap with the head transactions
|
||||
heads := make(OrderTxByNonce, 0, len(txs))
|
||||
for from, accTxs := range txs {
|
||||
if len(accTxs) == 0 {
|
||||
continue
|
||||
}
|
||||
heads = append(heads, accTxs[0])
|
||||
// Ensure the sender address is from the signer
|
||||
acc, _ := OrderSender(signer, accTxs[0])
|
||||
|
|
|
|||
31
core/types/order_transaction_test.go
Normal file
31
core/types/order_transaction_test.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/crypto"
|
||||
)
|
||||
|
||||
func TestNewOrderTransactionByNonce(t *testing.T) {
|
||||
// Generate a batch of accounts to start with
|
||||
keys := make([]*ecdsa.PrivateKey, 1)
|
||||
for i := 0; i < len(keys); i++ {
|
||||
keys[i], _ = crypto.GenerateKey()
|
||||
}
|
||||
|
||||
groups := map[common.Address]OrderTransactions{}
|
||||
for start, key := range keys {
|
||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||
for i := 0; i < 1; i++ {
|
||||
//tx, _ := SignTx(NewTransaction(uint64(start+i), common.Address{}, big.NewInt(100), 100, big.NewInt(int64(start+i)), nil), signer, key)
|
||||
orderTx := NewOrderTransaction(uint64(start+i), big.NewInt(1), big.NewInt(2), common.Address{}, common.Address{}, common.Address{}, common.Address{}, "new", "BID", "test", common.Hash{}, 1001)
|
||||
|
||||
groups[addr] = append(groups[addr], orderTx)
|
||||
}
|
||||
}
|
||||
tx := NewOrderTransactionByNonce(OrderTxSigner{}, groups)
|
||||
t.Log(tx)
|
||||
}
|
||||
Loading…
Reference in a new issue