@@ -64,6 +64,15 @@ describe("Tests Unsigned Transaction Serializing", function() {
6464 assert . equal ( tx . unsignedSerialized , test . unsignedLondon , "unsignedLondon" ) ;
6565 } ) ;
6666 }
67+
68+ for ( const test of tests ) {
69+ if ( ! test . unsignedCancun ) { continue ; }
70+ it ( `serialized unsigned cancun transaction: ${ test . name } ` , function ( ) {
71+ const txData = Object . assign ( { } , test . transaction , { type : 3 } ) ;
72+ const tx = Transaction . from ( txData ) ;
73+ assert . equal ( tx . unsignedSerialized , test . unsignedCancun , "unsignedCancun" ) ;
74+ } ) ;
75+ }
6776} ) ;
6877
6978describe ( "Tests Signed Transaction Serializing" , function ( ) {
@@ -127,6 +136,20 @@ describe("Tests Signed Transaction Serializing", function() {
127136 assert . equal ( tx . serialized , test . signedLondon , "signedLondon" ) ;
128137 } ) ;
129138 }
139+
140+ for ( const test of tests ) {
141+ if ( ! test . signedCancun ) { continue ; }
142+
143+ it ( `serialized signed Cancun transaction: ${ test . name } ` , function ( ) {
144+ const txData = Object . assign ( { } , test . transaction , {
145+ type : 3 ,
146+ signature : test . signatureCancun
147+ } ) ;
148+
149+ const tx = Transaction . from ( txData ) ;
150+ assert . equal ( tx . serialized , test . signedCancun , "signedCancun" ) ;
151+ } ) ;
152+ }
130153} ) ;
131154
132155function assertTxUint ( actual : null | bigint , _expected : undefined | string , name : string ) : void {
@@ -227,6 +250,18 @@ describe("Tests Unsigned Transaction Parsing", function() {
227250 assertTxEqual ( tx , expected ) ;
228251 } ) ;
229252 }
253+
254+ for ( const test of tests ) {
255+ if ( ! test . unsignedCancun ) { continue ; }
256+ it ( `parses unsigned Cancun transaction: ${ test . name } ` , function ( ) {
257+ const tx = Transaction . from ( test . unsignedCancun ) ;
258+
259+ const expected = addDefaults ( test . transaction ) ;
260+ expected . gasPrice = null ;
261+
262+ assertTxEqual ( tx , expected ) ;
263+ } ) ;
264+ }
230265} ) ;
231266
232267describe ( "Tests Signed Transaction Parsing" , function ( ) {
@@ -277,6 +312,7 @@ describe("Tests Signed Transaction Parsing", function() {
277312 assert . equal ( tx . isLegacy ( ) , true , "isLegacy" ) ;
278313 assert . equal ( tx . isBerlin ( ) , false , "isBerlin" ) ;
279314 assert . equal ( tx . isLondon ( ) , false , "isLondon" ) ;
315+ assert . equal ( tx . isCancun ( ) , false , "isCancun" ) ;
280316
281317 assert . ok ( ! ! tx . signature , "signature:!null" )
282318 assert . equal ( tx . signature . r , test . signatureEip155 . r , "signature.r" ) ;
@@ -303,6 +339,7 @@ describe("Tests Signed Transaction Parsing", function() {
303339 assert . equal ( tx . isLegacy ( ) , false , "isLegacy" ) ;
304340 assert . equal ( tx . isBerlin ( ) , true , "isBerlin" ) ;
305341 assert . equal ( tx . isLondon ( ) , false , "isLondon" ) ;
342+ assert . equal ( tx . isCancun ( ) , false , "isCancun" ) ;
306343
307344 assert . ok ( ! ! tx . signature , "signature:!null" )
308345 assert . equal ( tx . signature . r , test . signatureBerlin . r , "signature.r" ) ;
@@ -328,6 +365,7 @@ describe("Tests Signed Transaction Parsing", function() {
328365 assert . equal ( tx . isLegacy ( ) , false , "isLegacy" ) ;
329366 assert . equal ( tx . isBerlin ( ) , false , "isBerlin" ) ;
330367 assert . equal ( tx . isLondon ( ) , true , "isLondon" ) ;
368+ assert . equal ( tx . isCancun ( ) , false , "isCancun" ) ;
331369
332370 assert . ok ( ! ! tx . signature , "signature:!null" )
333371 assert . equal ( tx . signature . r , test . signatureLondon . r , "signature.r" ) ;
@@ -339,6 +377,34 @@ describe("Tests Signed Transaction Parsing", function() {
339377 }
340378 } ) ;
341379 }
380+
381+ for ( const test of tests ) {
382+ if ( ! test . signedCancun ) { continue ; }
383+ it ( `parses signed Cancun transaction: ${ test . name } ` , function ( ) {
384+ let tx = Transaction . from ( test . signedCancun ) ;
385+
386+ const expected = addDefaults ( test . transaction ) ;
387+ expected . gasPrice = null ;
388+
389+ for ( let i = 0 ; i < 2 ; i ++ ) {
390+ assertTxEqual ( tx , expected ) ;
391+
392+ assert . equal ( tx . typeName , "eip-4844" , "typeName" ) ;
393+ assert . equal ( tx . isLegacy ( ) , false , "isLegacy" ) ;
394+ assert . equal ( tx . isBerlin ( ) , false , "isBerlin" ) ;
395+ assert . equal ( tx . isLondon ( ) , false , "isLondon" ) ;
396+ assert . equal ( tx . isCancun ( ) , true , "isCancun" ) ;
397+
398+ assert . ok ( ! ! tx . signature , "signature:!null" )
399+ assert . equal ( tx . signature . r , test . signatureCancun . r , "signature.r" ) ;
400+ assert . equal ( tx . signature . s , test . signatureCancun . s , "signature.s" ) ;
401+ assert . equal ( tx . signature . yParity , parseInt ( test . signatureCancun . v ) , "signature.v" ) ;
402+
403+ // Test cloning
404+ tx = tx . clone ( ) ;
405+ }
406+ } ) ;
407+ }
342408} ) ;
343409
344410describe ( "Tests Transaction Parameters" , function ( ) {
0 commit comments