1414 */
1515package org .hyperledger .besu .ethereum .core ;
1616
17- import static java .util .stream .Collectors .toUnmodifiableSet ;
1817import static org .assertj .core .api .Assertions .assertThat ;
18+ import static org .hyperledger .besu .datatypes .VersionedHash .DEFAULT_VERSIONED_HASH ;
1919import static org .junit .jupiter .api .Assertions .assertEquals ;
2020import static org .junit .jupiter .api .Assertions .fail ;
2121
2222import org .hyperledger .besu .crypto .KeyPair ;
23+ import org .hyperledger .besu .crypto .SECPSignature ;
2324import org .hyperledger .besu .crypto .SignatureAlgorithm ;
2425import org .hyperledger .besu .crypto .SignatureAlgorithmFactory ;
2526import org .hyperledger .besu .datatypes .AccessListEntry ;
27+ import org .hyperledger .besu .datatypes .Address ;
2628import org .hyperledger .besu .datatypes .TransactionType ;
2729import org .hyperledger .besu .datatypes .Wei ;
2830import org .hyperledger .besu .ethereum .rlp .BytesValueRLPOutput ;
2931
3032import java .math .BigInteger ;
3133import java .util .List ;
3234import java .util .Optional ;
33- import java .util .Set ;
3435import java .util .function .Supplier ;
3536import java .util .stream .Stream ;
3637
@@ -45,20 +46,51 @@ class TransactionBuilderTest {
4546 @ Test
4647 void guessTypeCanGuessAllTypes () {
4748 final BlockDataGenerator gen = new BlockDataGenerator ();
49+ final List <AccessListEntry > accessList =
50+ List .of (new AccessListEntry (gen .address (), List .of (gen .bytes32 ())));
51+
4852 final Transaction .Builder frontierBuilder = Transaction .builder ();
49- final Transaction .Builder eip1559Builder = Transaction .builder ().maxFeePerGas (Wei .of (5 ));
50- final Transaction .Builder accessListBuilder =
53+ final Transaction .Builder accessListBuilder = Transaction .builder ().accessList (accessList );
54+
55+ final Transaction .Builder eip1559Builder =
56+ Transaction .builder ().accessList (accessList ).maxFeePerGas (Wei .of (5 ));
57+
58+ final Transaction .Builder blobBuilder =
59+ Transaction .builder ()
60+ .accessList (accessList )
61+ .maxFeePerGas (Wei .of (5 ))
62+ .versionedHashes (List .of (DEFAULT_VERSIONED_HASH ));
63+
64+ final CodeDelegation codeDelegation =
65+ new CodeDelegation (
66+ BigInteger .ZERO ,
67+ Address .ZERO ,
68+ 0 ,
69+ new SECPSignature (BigInteger .ZERO , BigInteger .ZERO , (byte ) 0 ));
70+
71+ final Transaction .Builder delegateCodeBuilder =
5172 Transaction .builder ()
52- .accessList (List .of (new AccessListEntry (gen .address (), List .of (gen .bytes32 ()))));
73+ .accessList (accessList )
74+ .maxFeePerGas (Wei .of (5 ))
75+ .codeDelegations (List .of (codeDelegation ));
5376
54- final Set <TransactionType > guessedTypes =
55- Stream .of (frontierBuilder , eip1559Builder , accessListBuilder )
77+ final List <TransactionType > guessedTypes =
78+ Stream .of (
79+ frontierBuilder ,
80+ accessListBuilder ,
81+ eip1559Builder ,
82+ blobBuilder ,
83+ delegateCodeBuilder )
5684 .map (transactionBuilder -> transactionBuilder .guessType ().getTransactionType ())
57- .collect ( toUnmodifiableSet () );
85+ .toList ( );
5886
5987 assertThat (guessedTypes )
60- .containsExactlyInAnyOrder (
61- TransactionType .FRONTIER , TransactionType .ACCESS_LIST , TransactionType .EIP1559 );
88+ .containsExactly (
89+ TransactionType .FRONTIER ,
90+ TransactionType .ACCESS_LIST ,
91+ TransactionType .EIP1559 ,
92+ TransactionType .BLOB ,
93+ TransactionType .DELEGATE_CODE );
6294 }
6395
6496 @ Test
0 commit comments