Skip to content

Commit

Permalink
feat:add decode v1 test
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Kai <[email protected]>
  • Loading branch information
GrapeBaBa committed Sep 2, 2024
1 parent 4e8b420 commit fec6d98
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
7 changes: 7 additions & 0 deletions crates/net/src/types/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ mod tests {
use super::*;
use alloy::hex;

#[test]
fn decode_v1() {
let data = hex::decode("0xbd04f043128457c6ccf35128497167442bcc0f8cce78cda8b366e6a12e526d938d1e4c1046acffffbfc542a7e212bb7d80d3a4b2f84f7b196d935398a24eb84c519789b401000000fe0300fe0300fe0300fe0300fe0300fe0300a203000c4a8fd56621ad04fc0101067601008ce60be0005b220117c32c0f3b394b346c2aa42cfa8157cd41f891aa0bec485a62fc010000").unwrap();
let payload_envelop = ExecutionPayloadEnvelope::decode_v1(&data).unwrap();
assert_eq!(1725271882, payload_envelop.payload.timestamp);
}

#[test]
fn decode_v2() {
let data = hex::decode("0xc104f0433805080eb36c0b130a7cc1dc74c3f721af4e249aa6f61bb89d1557143e971bb738a3f3b98df7c457e74048e9d2d7e5cd82bb45e3760467e2270e9db86d1271a700000000fe0300fe0300fe0300fe0300fe0300fe0300a203000c6b89d46525ad000205067201009cda69cb5b9b73fc4eb2458b37d37f04ff507fe6c9cd2ab704a05ea9dae3cd61760002000000020000").unwrap();
Expand Down
20 changes: 4 additions & 16 deletions crates/net/src/types/payload.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
//! Execution Payload Types
use alloy::{
primitives::{keccak256, B256},
rpc::types::engine::ExecutionPayloadV3,
};
use kona_primitives::L2ExecutionPayload;
use ssz_rs::{prelude::*, List, Vector, U256};

/// A type alias for a vector of 32 bytes, representing a Bytes32 hash
type Bytes32 = Vector<u8, 32>;

/// A type alias for a vector of 20 bytes, representing an address
type VecAddress = Vector<u8, 20>;

/// A type alias for a byte list, representing a transaction
type Transaction = List<u8, 1073741824>;
use alloy::primitives::{keccak256, B256};
use ssz_rs::prelude::*;

/// Represents the Keccak256 hash of the block
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
Expand All @@ -39,9 +26,10 @@ impl PayloadHash {

#[cfg(test)]
mod tests {
use super::*;
use alloy::primitives::b256;

use super::*;

#[test]
fn test_signature_message() {
let inner = b256!("9999999999999999999999999999999999999999999999999999999999999999");
Expand Down

0 comments on commit fec6d98

Please sign in to comment.