This commit is contained in:
aodhgan 2025-10-12 23:13:14 -07:00
parent 2ed437e361
commit 3aa3538507
3 changed files with 13 additions and 19 deletions

View file

@ -1694,7 +1694,7 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
for { for {
select { select {
case <-receiptCtx.Done(): case <-receiptCtx.Done():
// Upstream cancellation -> bubble it; otherwise emit our timeout error // Upstream cancellation -> bubble it; otherwise emit the timeout error
if err := ctx.Err(); err != nil { if err := ctx.Err(); err != nil {
return nil, err return nil, err
} }

View file

@ -447,8 +447,8 @@ type testBackend struct {
sentTx *types.Transaction sentTx *types.Transaction
sentTxHash common.Hash sentTxHash common.Hash
syncDefaultTO time.Duration syncDefaultTimeout time.Duration
syncMaxTO time.Duration syncMaxTimeout time.Duration
} }
func fakeBlockHash(txh common.Hash) common.Hash { func fakeBlockHash(txh common.Hash) common.Hash {
@ -613,24 +613,20 @@ func (b *testBackend) SendTx(ctx context.Context, tx *types.Transaction) error {
if b.autoMine { if b.autoMine {
// Synthesize a "mined" receipt at head+1 // Synthesize a "mined" receipt at head+1
num := b.chain.CurrentHeader().Number.Uint64() + 1 num := b.chain.CurrentHeader().Number.Uint64() + 1
bh := fakeBlockHash(tx.Hash())
receipt := &types.Receipt{ receipt := &types.Receipt{
TxHash: tx.Hash(), TxHash: tx.Hash(),
Status: types.ReceiptStatusSuccessful, Status: types.ReceiptStatusSuccessful,
BlockHash: bh, BlockHash: fakeBlockHash(tx.Hash()),
BlockNumber: new(big.Int).SetUint64(num), BlockNumber: new(big.Int).SetUint64(num),
TransactionIndex: 0, TransactionIndex: 0,
CumulativeGasUsed: 21000, CumulativeGasUsed: 21000,
GasUsed: 21000, GasUsed: 21000,
} }
hdr := &types.Header{
Number: new(big.Int).SetUint64(num),
}
// Broadcast a ChainEvent that includes the receipts and txs // Broadcast a ChainEvent that includes the receipts and txs
b.chainFeed.Send(core.ChainEvent{ b.chainFeed.Send(core.ChainEvent{
Header: hdr, Header: &types.Header{
Number: new(big.Int).SetUint64(num),
},
Receipts: types.Receipts{receipt}, Receipts: types.Receipts{receipt},
Transactions: types.Transactions{tx}, Transactions: types.Transactions{tx},
}) })
@ -3954,14 +3950,14 @@ func (b configTimeBackend) CurrentHeader() *types.Header {
} }
func (b *testBackend) RPCTxSyncDefaultTimeout() time.Duration { func (b *testBackend) RPCTxSyncDefaultTimeout() time.Duration {
if b.syncDefaultTO != 0 { if b.syncDefaultTimeout != 0 {
return b.syncDefaultTO return b.syncDefaultTimeout
} }
return 2 * time.Second return 2 * time.Second
} }
func (b *testBackend) RPCTxSyncMaxTimeout() time.Duration { func (b *testBackend) RPCTxSyncMaxTimeout() time.Duration {
if b.syncMaxTO != 0 { if b.syncMaxTimeout != 0 {
return b.syncMaxTO return b.syncMaxTimeout
} }
return 5 * time.Minute return 5 * time.Minute
} }

View file

@ -178,6 +178,4 @@ func (e *blockGasLimitReachedError) ErrorCode() int { return errCodeBlockGasLimi
func (e *txSyncTimeoutError) Error() string { return e.msg } func (e *txSyncTimeoutError) Error() string { return e.msg }
func (e *txSyncTimeoutError) ErrorCode() int { return errCodeTxSyncTimeout } func (e *txSyncTimeoutError) ErrorCode() int { return errCodeTxSyncTimeout }
// ErrorData should be JSON-safe; return the 0x-hex string.
func (e *txSyncTimeoutError) ErrorData() interface{} { return e.hash.Hex() } func (e *txSyncTimeoutError) ErrorData() interface{} { return e.hash.Hex() }