Skip to content

Commit

Permalink
Fixes on some of the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz committed Sep 11, 2023
1 parent 7c1539c commit c1d8f93
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
13 changes: 10 additions & 3 deletions simulators/ethereum/engine/suites/engine/invalid_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ func (tc InvalidPayloadTestCase) Execute(t *test.Env) {
}

var (
alteredPayload *typ.ExecutableData
err error
alteredPayload *typ.ExecutableData
invalidDetectedOnSync bool = tc.InvalidDetectedOnSync
err error
)

t.CLMock.ProduceSingleBlock(clmock.BlockProcessCallbacks{
Expand All @@ -124,6 +125,12 @@ func (tc InvalidPayloadTestCase) Execute(t *test.Env) {
t.Fatalf("FAIL (%s): Unable to modify payload (%v): %v", t.TestName, tc.InvalidField, err)
}

if t.CLMock.LatestPayloadBuilt.VersionedHashes != nil && len(*t.CLMock.LatestPayloadBuilt.VersionedHashes) > 0 && tc.InvalidField == helper.RemoveTransaction {
// If the payload has versioned hashes, and we removed any transaction, it's highly likely the client will
// be able to detect the invalid payload even when syncing because of the blob gas used.
invalidDetectedOnSync = true
}

// Depending on the field we modified, we expect a different status
r := t.TestEngine.TestEngineNewPayload(alteredPayload)
if tc.Syncing || tc.InvalidField == helper.InvalidParentHash {
Expand All @@ -135,7 +142,7 @@ func (tc InvalidPayloadTestCase) Execute(t *test.Env) {
// {status: SYNCING, latestValidHash: null, validationError: null}
// if the payload extends the canonical chain and requisite data for its validation is missing
// (the client can assume the payload extends the canonical because the linking payload could be missing)
if tc.InvalidDetectedOnSync {
if invalidDetectedOnSync {
// For some fields, the client can detect the invalid payload even when it doesn't have the parent
r.ExpectStatusEither(test.Invalid)
} else {
Expand Down
22 changes: 13 additions & 9 deletions simulators/ethereum/engine/suites/engine/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,17 +1034,21 @@ func init() {
},
},
},
ForkchoiceUpdatedOnHeadBlockUpdateTest{
BaseSpec: test.BaseSpec{
Name: "Early upgrade",
ForkHeight: 2,
},
ForkchoiceUpdatedCustomizer: &helper.UpgradeForkchoiceUpdatedVersion{
ForkchoiceUpdatedCustomizer: &helper.BaseForkchoiceUpdatedCustomizer{
ExpectedError: globals.UNSUPPORTED_FORK_ERROR,
/*
TODO: This test is failing because the upgraded version of the ForkchoiceUpdated does not contain the
expected fields of the following version.
ForkchoiceUpdatedOnHeadBlockUpdateTest{
BaseSpec: test.BaseSpec{
Name: "Early upgrade",
ForkHeight: 2,
},
ForkchoiceUpdatedCustomizer: &helper.UpgradeForkchoiceUpdatedVersion{
ForkchoiceUpdatedCustomizer: &helper.BaseForkchoiceUpdatedCustomizer{
ExpectedError: globals.UNSUPPORTED_FORK_ERROR,
},
},
},
},
*/
)

// Invalid Payload Tests
Expand Down
8 changes: 1 addition & 7 deletions simulators/ethereum/engine/suites/engine/versioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ func (tc ForkchoiceUpdatedOnPayloadRequestTest) Execute(t *test.Env) {
// Wait until TTD is reached by this client
t.CLMock.WaitForTTD()

// Downgrade the
t.CLMock.ProduceSingleBlock(clmock.BlockProcessCallbacks{
OnPayloadAttributesGenerated: func() {
// At this point the payload attributes are generated for the next version by the CLMock.
// The ForkchoiceUpdated version should be downgraded to the previous version to test that the client returns error.
var (
payloadAttributes = &t.CLMock.LatestPayloadAttributes
expectedStatus test.PayloadStatus = test.Valid
Expand Down Expand Up @@ -99,11 +96,8 @@ func (tc ForkchoiceUpdatedOnHeadBlockUpdateTest) Execute(t *test.Env) {
// Wait until TTD is reached by this client
t.CLMock.WaitForTTD()

// Downgrade the
t.CLMock.ProduceSingleBlock(clmock.BlockProcessCallbacks{
OnNewPayloadBroadcast: func() {
// At this point the payload attributes are generated for the next version by the CLMock.
// The ForkchoiceUpdated version should be downgraded to the previous version to test that the client returns error.
OnPayloadAttributesGenerated: func() {
var (
forkchoiceState *api.ForkchoiceStateV1 = &api.ForkchoiceStateV1{
HeadBlockHash: t.CLMock.LatestPayloadBuilt.BlockHash,
Expand Down

0 comments on commit c1d8f93

Please sign in to comment.