mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
test(raw_db): add more L1Origin tests (#427)
This commit is contained in:
parent
187f85d772
commit
d0c33f5baf
2 changed files with 10 additions and 6 deletions
|
|
@ -50,8 +50,9 @@ type l1OriginMarshaling struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsPreconfBlock returns true if the L1Origin is for a preconfirmation block.
|
// IsPreconfBlock returns true if the L1Origin is for a preconfirmation block.
|
||||||
|
// A preconfirmation block is defined as one where the L1BlockHeight is either nil or zero.
|
||||||
func (l *L1Origin) IsPreconfBlock() bool {
|
func (l *L1Origin) IsPreconfBlock() bool {
|
||||||
return l.L1BlockHeight == nil
|
return l.L1BlockHeight == nil || l.L1BlockHeight.Cmp(common.Big0) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteL1Origin stores a L1Origin into the database.
|
// WriteL1Origin stores a L1Origin into the database.
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,10 @@ func TestL1Origin(t *testing.T) {
|
||||||
testL1Origin := &L1Origin{
|
testL1Origin := &L1Origin{
|
||||||
BlockID: randomBigInt(),
|
BlockID: randomBigInt(),
|
||||||
L2BlockHash: randomHash(),
|
L2BlockHash: randomHash(),
|
||||||
L1BlockHeight: randomBigInt(),
|
// L1BlockHeight is intentionally set to nil to represent a value of zero for legacy behavior.
|
||||||
|
L1BlockHeight: nil,
|
||||||
L1BlockHash: randomHash(),
|
L1BlockHash: randomHash(),
|
||||||
|
BuildPayloadArgsID: [8]byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8},
|
||||||
}
|
}
|
||||||
WriteL1Origin(db, testL1Origin.BlockID, testL1Origin)
|
WriteL1Origin(db, testL1Origin.BlockID, testL1Origin)
|
||||||
l1Origin, err := ReadL1Origin(db, testL1Origin.BlockID)
|
l1Origin, err := ReadL1Origin(db, testL1Origin.BlockID)
|
||||||
|
|
@ -44,8 +46,9 @@ func TestL1Origin(t *testing.T) {
|
||||||
require.NotNil(t, l1Origin)
|
require.NotNil(t, l1Origin)
|
||||||
assert.Equal(t, testL1Origin.BlockID, l1Origin.BlockID)
|
assert.Equal(t, testL1Origin.BlockID, l1Origin.BlockID)
|
||||||
assert.Equal(t, testL1Origin.L2BlockHash, l1Origin.L2BlockHash)
|
assert.Equal(t, testL1Origin.L2BlockHash, l1Origin.L2BlockHash)
|
||||||
assert.Equal(t, testL1Origin.L1BlockHeight, l1Origin.L1BlockHeight)
|
assert.True(t, l1Origin.L1BlockHeight.Cmp(common.Big0) == 0)
|
||||||
assert.Equal(t, testL1Origin.L1BlockHash, l1Origin.L1BlockHash)
|
assert.Equal(t, testL1Origin.L1BlockHash, l1Origin.L1BlockHash)
|
||||||
|
assert.Equal(t, testL1Origin.BuildPayloadArgsID, l1Origin.BuildPayloadArgsID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHeadL1Origin(t *testing.T) {
|
func TestHeadL1Origin(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue