forked from hyperledger/besu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: garyschulte <[email protected]>
- Loading branch information
1 parent
3b99163
commit b6689c9
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
besu/src/test/java/org/hyperledger/besu/services/RlpConverterServiceImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.hyperledger.besu.services; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.hyperledger.besu.datatypes.BlobGas; | ||
import org.hyperledger.besu.datatypes.Hash; | ||
import org.hyperledger.besu.datatypes.Wei; | ||
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; | ||
import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; | ||
import org.hyperledger.besu.plugin.data.BlockHeader; | ||
|
||
import org.apache.tuweni.bytes.Bytes; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class RlpConverterServiceImplTest { | ||
|
||
@Test | ||
public void testBuildRlpFromHeader() { | ||
// Arrange | ||
RlpConverterServiceImpl rlpConverterServiceImpl = | ||
new RlpConverterServiceImpl(ProtocolScheduleFixture.MAINNET); | ||
// header with cancun fields | ||
BlockHeader header = | ||
new BlockHeaderTestFixture() | ||
.timestamp(1710338135 + 1) | ||
.baseFeePerGas(Wei.of(1000)) | ||
.depositsRoot(Hash.ZERO) | ||
.withdrawalsRoot(Hash.ZERO) | ||
.blobGasUsed(500L) | ||
.excessBlobGas(BlobGas.of(500L)) | ||
.buildHeader(); | ||
|
||
Bytes rlpBytes = rlpConverterServiceImpl.buildRlpFromHeader(header); | ||
BlockHeader deserialized = rlpConverterServiceImpl.buildHeaderFromRlp(rlpBytes); | ||
// Assert | ||
assertThat(header).isEqualTo(deserialized); | ||
assertThat(header.getBlobGasUsed()).isEqualTo(deserialized.getBlobGasUsed()); | ||
assertThat(header.getExcessBlobGas()).isEqualTo(deserialized.getExcessBlobGas()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters