This repository was archived by the owner on Mar 5, 2025. It is now read-only.
File tree 2 files changed +50
-1
lines changed
packages/web3-core-helpers
2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -300,7 +300,11 @@ export const outputBlockFormatter = (block) => {
300
300
block . gasLimit = Utils . hexToNumber ( block . gasLimit ) ;
301
301
block . gasUsed = Utils . hexToNumber ( block . gasUsed ) ;
302
302
block . size = Utils . hexToNumber ( block . size ) ;
303
- block . timestamp = Utils . hexToNumber ( block . timestamp ) ;
303
+
304
+ // Support Quorum 2.2.0 - timestamp is not present in the Quorum getBlock response
305
+ if ( block . timestamp !== null ) {
306
+ block . timestamp = Utils . hexToNumber ( block . timestamp ) ;
307
+ }
304
308
305
309
if ( block . number !== null ) {
306
310
block . number = Utils . hexToNumber ( block . number ) ;
Original file line number Diff line number Diff line change @@ -51,4 +51,49 @@ describe('OutputBlockFormatterTest', () => {
51
51
miner : '0x03C9A938fF7f54090d0d99e2c6f80380510Ea078'
52
52
} ) ;
53
53
} ) ;
54
+ it ( '[Quorum] call outputBlockFormatter with a valid block without a timestamp' , ( ) => {
55
+ const block = {
56
+ gasLimit : 0x0 ,
57
+ gasUsed : 0x0 ,
58
+ size : 0x0 ,
59
+ number : 0x0 ,
60
+ difficulty : 100 ,
61
+ totalDifficulty : 100 ,
62
+ transactions : [
63
+ {
64
+ blockNumber : 0 ,
65
+ transactionIndex : 0 ,
66
+ gas : 100 ,
67
+ gasPrice : 100 ,
68
+ nonce : 1 ,
69
+ value : 100 ,
70
+ to : '0x03c9a938ff7f54090d0d99e2c6f80380510ea078' ,
71
+ from : '0x03c9a938ff7f54090d0d99e2c6f80380510ea078'
72
+ }
73
+ ] ,
74
+ miner : '0x03c9a938ff7f54090d0d99e2c6f80380510ea078'
75
+ } ;
76
+
77
+ expect ( outputBlockFormatter ( block ) ) . toEqual ( {
78
+ gasLimit : 0x0 ,
79
+ gasUsed : 0x0 ,
80
+ size : 0x0 ,
81
+ number : 0x0 ,
82
+ difficulty : '100' , // Strange some numbers will be handled as string and some as number (gas & nonce)
83
+ totalDifficulty : '100' ,
84
+ transactions : [
85
+ {
86
+ blockNumber : 0 ,
87
+ transactionIndex : 0 ,
88
+ gas : 100 ,
89
+ gasPrice : '100' ,
90
+ nonce : 1 ,
91
+ value : '100' ,
92
+ to : '0x03C9A938fF7f54090d0d99e2c6f80380510Ea078' ,
93
+ from : '0x03C9A938fF7f54090d0d99e2c6f80380510Ea078'
94
+ }
95
+ ] ,
96
+ miner : '0x03C9A938fF7f54090d0d99e2c6f80380510Ea078'
97
+ } ) ;
98
+ } ) ;
54
99
} ) ;
You can’t perform that action at this time.
0 commit comments