From b966daedc8a6ececf8b98a1410904e9db762640f Mon Sep 17 00:00:00 2001 From: ~MarcusWentz Date: Wed, 1 Jun 2022 02:08:21 -0400 Subject: [PATCH 1/2] Struct length and TransitionConfigurationV1 tests --- simulators/ethereum/engine/engineclient.go | 89 +++++ simulators/ethereum/engine/enginetests.go | 313 ++++++++++++++++++ .../ethereum/engine/gen_blockparamsBytes.go | 52 +++ simulators/ethereum/engine/gen_edBytes.go | 138 ++++++++ .../engine/gen_transitionconfBytes.go | 53 +++ simulators/ethereum/engine/teststruct.go | 73 ++++ 6 files changed, 718 insertions(+) create mode 100644 simulators/ethereum/engine/gen_blockparamsBytes.go create mode 100644 simulators/ethereum/engine/gen_edBytes.go create mode 100644 simulators/ethereum/engine/gen_transitionconfBytes.go diff --git a/simulators/ethereum/engine/engineclient.go b/simulators/ethereum/engine/engineclient.go index 85730371a2..4ffc88aab5 100644 --- a/simulators/ethereum/engine/engineclient.go +++ b/simulators/ethereum/engine/engineclient.go @@ -242,6 +242,11 @@ type ForkchoiceStateV1 struct { FinalizedBlockHash common.Hash `json:"finalizedBlockHash"` } +type ForkchoiceStateBytes struct { + HeadBlockHash hexutil.Bytes `json:"headBlockHash"` + SafeBlockHash hexutil.Bytes `json:"safeBlockHash"` + FinalizedBlockHash hexutil.Bytes `json:"finalizedBlockHash"` +} //go:generate go run github.com/fjl/gencodec -type ExecutableDataV1 -field-override executableDataMarshaling -out gen_ed.go // ExecutableDataV1 structure described at https://github.com/ethereum/execution-apis/src/engine/specification.md type ExecutableDataV1 struct { @@ -273,6 +278,37 @@ type executableDataMarshaling struct { Transactions []hexutil.Bytes } + +//go:generate go run github.com/fjl/gencodec -type ExecutableDataByteType -field-override executableDataMarshalingByteType -out gen_edBytes.go +type ExecutableDataByteType struct { + ParentHash hexutil.Bytes `json:"parentHash" gencodec:"required"` + FeeRecipient hexutil.Bytes `json:"feeRecipient" gencodec:"required"` + StateRoot hexutil.Bytes `json:"stateRoot" gencodec:"required"` + ReceiptsRoot hexutil.Bytes `json:"receiptsRoot" gencodec:"required"` + LogsBloom []byte `json:"logsBloom" gencodec:"required"` + PrevRandao hexutil.Bytes `json:"prevRandao" gencodec:"required"` + Number uint64 `json:"blockNumber" gencodec:"required"` + GasLimit uint64 `json:"gasLimit" gencodec:"required"` + GasUsed uint64 `json:"gasUsed" gencodec:"required"` + Timestamp uint64 `json:"timestamp" gencodec:"required"` + ExtraData []byte `json:"extraData" gencodec:"required"` + BaseFeePerGas *big.Int `json:"baseFeePerGas" gencodec:"required"` + BlockHash hexutil.Bytes `json:"blockHash" gencodec:"required"` + Transactions [][]byte `json:"transactions" gencodec:"required"` +} + +// JSON type overrides for executableData. +type executableDataMarshalingByteType struct { + Number hexutil.Uint64 + GasLimit hexutil.Uint64 + GasUsed hexutil.Uint64 + Timestamp hexutil.Uint64 + BaseFeePerGas *hexutil.Big + ExtraData hexutil.Bytes + LogsBloom hexutil.Bytes + Transactions []hexutil.Bytes +} + //go:generate go run github.com/fjl/gencodec -type PayloadAttributesV1 -field-override payloadAttributesMarshaling -out gen_blockparams.go // PayloadAttributesV1 structure described at https://github.com/ethereum/execution-apis/pull/74 type PayloadAttributesV1 struct { @@ -286,6 +322,19 @@ type payloadAttributesMarshaling struct { Timestamp hexutil.Uint64 } +//go:generate go run github.com/fjl/gencodec -type PayloadAttributesBytes -field-override payloadAttributesMarshalingBytes -out gen_blockparamsBytes.go +// PayloadAttributesBytes structure described at https://github.com/ethereum/execution-apis/pull/74 +type PayloadAttributesBytes struct { + Timestamp uint64 `json:"timestamp" gencodec:"required"` + PrevRandao hexutil.Bytes `json:"prevRandao" gencodec:"required"` + SuggestedFeeRecipient hexutil.Bytes `json:"suggestedFeeRecipient" gencodec:"required"` +} + +// JSON type overrides for PayloadAttributesV1. +type payloadAttributesMarshalingBytes struct { + Timestamp hexutil.Uint64 +} + //go:generate go run github.com/fjl/gencodec -type TransitionConfigurationV1 -field-override TransitionConfigurationV1Marshaling -out gen_transitionconf.go type TransitionConfigurationV1 struct { TerminalTotalDifficulty *big.Int `json:"terminalTotalDifficulty" gencodec:"required"` @@ -299,6 +348,18 @@ type TransitionConfigurationV1Marshaling struct { TerminalBlockNumber hexutil.Uint64 `json:"terminalBlockNumber"` } +//go:generate go run github.com/fjl/gencodec -type TransitionConfigurationBytes -field-override TransitionConfigurationV1MarshalingBytes -out gen_transitionconfBytes.go +type TransitionConfigurationBytes struct { + TerminalTotalDifficulty *big.Int `json:"terminalTotalDifficulty" gencodec:"required"` + TerminalBlockHash hexutil.Bytes `json:"terminalBlockHash" gencodec:"required"` + TerminalBlockNumber uint64 `json:"terminalBlockNumber" gencodec:"required"` +} + +// JSON type overrides for TransitionConfigurationV1. +type TransitionConfigurationV1MarshalingBytes struct { + TerminalTotalDifficulty *hexutil.Big `json:"terminalTotalDifficulty"` + TerminalBlockNumber hexutil.Uint64 `json:"terminalBlockNumber"` +} // JWT Tokens func GetNewToken(jwtSecretBytes []byte, iat time.Time) (string, error) { newToken := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ @@ -335,6 +396,16 @@ func (ec *EngineClient) EngineForkchoiceUpdatedV1(ctx context.Context, fcState * return result, err } +// Engine API Call Methods +func (ec *EngineClient) EngineForkchoiceUpdatedBytes(ctx context.Context, fcState *ForkchoiceStateBytes, pAttributes *PayloadAttributesBytes) (ForkChoiceResponse, error) { + var result ForkChoiceResponse + if err := ec.PrepareDefaultAuthCallToken(); err != nil { + return result, err + } + err := ec.c.CallContext(ctx, &result, "engine_forkchoiceUpdatedV1", fcState, pAttributes) + return result, err +} + func (ec *EngineClient) EngineGetPayloadV1(ctx context.Context, payloadId *PayloadID) (ExecutableDataV1, error) { var result ExecutableDataV1 if err := ec.PrepareDefaultAuthCallToken(); err != nil { @@ -353,6 +424,15 @@ func (ec *EngineClient) EngineNewPayloadV1(ctx context.Context, payload *Executa return result, err } +func (ec *EngineClient) EngineNewPayloadByteType(ctx context.Context, payload *ExecutableDataByteType) (PayloadStatusV1, error) { + var result PayloadStatusV1 + if err := ec.PrepareDefaultAuthCallToken(); err != nil { + return result, err + } + err := ec.c.CallContext(ctx, &result, "engine_newPayloadV1", payload) + return result, err +} + func (ec *EngineClient) EngineExchangeTransitionConfigurationV1(ctx context.Context, tConf *TransitionConfigurationV1) (TransitionConfigurationV1, error) { var result TransitionConfigurationV1 if err := ec.PrepareDefaultAuthCallToken(); err != nil { @@ -361,3 +441,12 @@ func (ec *EngineClient) EngineExchangeTransitionConfigurationV1(ctx context.Cont err := ec.c.CallContext(ctx, &result, "engine_exchangeTransitionConfigurationV1", tConf) return result, err } + +func (ec *EngineClient) EngineExchangeTransitionConfigurationBytes(ctx context.Context, tConf *TransitionConfigurationBytes) (TransitionConfigurationBytes, error) { + var result TransitionConfigurationBytes + if err := ec.PrepareDefaultAuthCallToken(); err != nil { + return result, err + } + err := ec.c.CallContext(ctx, &result, "engine_exchangeTransitionConfigurationV1", tConf) + return result, err +} diff --git a/simulators/ethereum/engine/enginetests.go b/simulators/ethereum/engine/enginetests.go index db10e4a4f2..bb194bb2d5 100644 --- a/simulators/ethereum/engine/enginetests.go +++ b/simulators/ethereum/engine/enginetests.go @@ -404,6 +404,76 @@ var engineTests = []TestSpec{ Run: postMergeSync, TTD: 10, }, + + //ExecutableDataV1 bytes to force invalid input tests. + { + Name: "ExecutableDataV1 ParentHash Length Errors", + Run: ExecutableDataV1_ParentHashLengthErrors, + }, + { + Name: "ExecutableDataV1 FeeRecipient Length Errors", + Run: ExecutableDataV1_FeeRecipientLengthErrors, + }, + { + Name: "ExecutableDataV1 StateRoot Length Errors", + Run: ExecutableDataV1_StateRootLengthErrors, + }, + { + Name: "ExecutableDataV1 ReceiptsRoot Length Errors", + Run: ExecutableDataV1_ReceiptsRootLengthErrors, + }, + { + Name: "ExecutableDataV1 LogsBloom Length Errors", + Run: ExecutableDataV1_LogsBloomLengthErrors, + }, + { + Name: "ExecutableDataV1 PrevRandao Length Errors", + Run: ExecutableDataV1_PrevRandaoLengthErrors, + }, + { + Name: "ExecutableDataV1 BlockHash Length Errors", + Run: ExecutableDataV1_BlockHashLengthErrors, + }, + //ForkchoiceStateV1 bytes to force invalid input tests. + { + Name: "ForkchoiceStateV1 HeadBlockHash Length Errors", + Run: ForkchoiceStateV1_HeadBlockHashLengthErrors, + }, + { + Name: "ForkchoiceStateV1 SafeBlockHash Length Errors", + Run: ForkchoiceStateV1_SafeBlockHashLengthErrors, + }, + { + Name: "ForkchoiceStateV1 FinalizedBlockHash Length Errors", + Run: ForkchoiceStateV1_FinalizedBlockHashLengthErrors, + }, + //PayloadAttributesV1 bytes input tests. + { + Name: "PayloadAttributesV1 PrevRandaoLength Errors", + Run: PayloadAttributesV1_PrevRandaoLengthErrors, + }, + { + Name: "PayloadAttributesV1 SuggestedFeeRecipient Length Errors", + Run: PayloadAttributesV1_SuggestedFeeRecipientLengthErrors, + }, + //TransitionConfigurationV1 TerminalTotalDifficulty correct and incorrect values. + { + Name: "TransitionConfigurationV1 CL_TTD Must Match EL_TTD", + Run: TransitionConfigurationV1_CL_TTD_Must_Match_EL_TTD, + }, + { + Name: "TransitionConfigurationV1 TerminalBlockNumber Not Zero", + Run: TransitionConfigurationV1_TerminalBlockNumberNotZero, + }, + { + Name: "TransitionConfigurationV1 TerminalBlockHash Not Zero", + Run: TransitionConfigurationV1_TerminalBlockHashNotZero, + }, + //TransitionConfigurationV1 bytes input tests. + { + Name: "TransitionConfigurationV1 TerminalBlockHash Length Errors", + Run: TransitionConfigurationV1_TerminalBlockHashLengthErrors, + }, } // Invalid Terminal Block in ForkchoiceUpdated: Client must reject ForkchoiceUpdated directives if the referenced HeadBlockHash does not meet the TTD requirement. @@ -2062,3 +2132,246 @@ func postMergeSync(t *TestEnv) { } } } + +func ExecutableDataByteGenesis(t *TestEnv) *ExecutableDataByteType{ + gblock := loadGenesisBlock(t.ClientFiles["/genesis.json"]) + alteredPayload := ExecutableDataByteType{ + ParentHash: gblock.Hash().Bytes(), + FeeRecipient: common.Address{}.Bytes(), + StateRoot: gblock.Root().Bytes(), + ReceiptsRoot: types.EmptyUncleHash.Bytes(), + LogsBloom: types.CreateBloom(types.Receipts{}).Bytes(), + PrevRandao: common.Hash{}.Bytes(), + Number: 1, + GasLimit: gblock.GasLimit(), + GasUsed: 0, + Timestamp: gblock.Time() + 1, + ExtraData: []byte{}, + BaseFeePerGas: gblock.BaseFee(), + BlockHash: common.Hash{}.Bytes(), + Transactions: [][]byte{}, + } + return &alteredPayload +} + +func ExecutableDataV1_ParentHashLengthErrors(t *TestEnv) { + alteredPayload:= ExecutableDataByteGenesis(t) + alteredPayload.ParentHash = common.FromHex("0x0067ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + prefix := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + prefix.ExpectError() + alteredPayload.ParentHash = common.FromHex("0x167ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + long := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + long.ExpectError() + alteredPayload.ParentHash = common.FromHex("0xead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + short := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + short.ExpectError() +} + +func ExecutableDataV1_FeeRecipientLengthErrors(t *TestEnv) { + alteredPayload:= ExecutableDataByteGenesis(t) + alteredPayload.FeeRecipient = common.FromHex("0x001000000000000000000000000000000000000000") + prefix := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + prefix.ExpectError() + alteredPayload.FeeRecipient = common.FromHex("0x10000000000000000000000000000000000000000") + long := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + long.ExpectError() + alteredPayload.FeeRecipient = common.FromHex("0x00000000000000000000000000000000000000") + short := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + short.ExpectError() +} + +func ExecutableDataV1_StateRootLengthErrors(t *TestEnv) { + alteredPayload:= ExecutableDataByteGenesis(t) + alteredPayload.StateRoot = common.FromHex("0x0084308e7d0abf860412f4a0c6fc25709a6e9eaba20a0d085a0344d271f40109ec") + prefix := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + prefix.ExpectError() + alteredPayload.StateRoot = common.FromHex("0x184308e7d0abf860412f4a0c6fc25709a6e9eaba20a0d085a0344d271f40109ec") + long := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + long.ExpectError() + alteredPayload.StateRoot = common.FromHex("0x308e7d0abf860412f4a0c6fc25709a6e9eaba20a0d085a0344d271f40109ec") + short := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + short.ExpectError() +} + +func ExecutableDataV1_ReceiptsRootLengthErrors(t *TestEnv) { + alteredPayload:= ExecutableDataByteGenesis(t) + alteredPayload.ReceiptsRoot = common.FromHex("0x001dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347") + prefix := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + prefix.ExpectError() + alteredPayload.ReceiptsRoot = common.FromHex("0x11dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347") + long := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + long.ExpectError() + alteredPayload.ReceiptsRoot = common.FromHex("0xcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347") + short := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + short.ExpectError() +} + +func ExecutableDataV1_LogsBloomLengthErrors(t *TestEnv) { + alteredPayload:= ExecutableDataByteGenesis(t) + alteredPayload.LogsBloom = common.FromHex("0x0010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") + prefix := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + prefix.ExpectError() + alteredPayload.LogsBloom = common.FromHex("0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") + long := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + long.ExpectError() + alteredPayload.LogsBloom = common.FromHex("0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") + short := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + short.ExpectError() +} + +func ExecutableDataV1_PrevRandaoLengthErrors(t *TestEnv) { + alteredPayload:= ExecutableDataByteGenesis(t) + alteredPayload.PrevRandao = common.FromHex("0x001000000000000000000000000000000000000000000000000000000000000000") + prefix := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + prefix.ExpectError() + alteredPayload.PrevRandao = common.FromHex("0x10000000000000000000000000000000000000000000000000000000000000000") + long := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + long.ExpectError() + alteredPayload.PrevRandao = common.FromHex("0x00000000000000000000000000000000000000000000000000000000000000") + short := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + short.ExpectError() +} + +func ExecutableDataV1_BlockHashLengthErrors(t *TestEnv) { + alteredPayload:= ExecutableDataByteGenesis(t) + alteredPayload.BlockHash = common.FromHex("0x001000000000000000000000000000000000000000000000000000000000000000") + prefix := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + prefix.ExpectError() + alteredPayload.BlockHash = common.FromHex("0x10000000000000000000000000000000000000000000000000000000000000000") + long := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + long.ExpectError() + alteredPayload.BlockHash = common.FromHex("0x00000000000000000000000000000000000000000000000000000000000000") + short := t.TestEngine.TestEngineNewPayloadByteType(alteredPayload) + short.ExpectError() +} + +func ForkchoiceStateBytesGenesis(t *TestEnv) *ForkchoiceStateBytes{ + forkchoiceState := ForkchoiceStateBytes{ + HeadBlockHash: common.FromHex("0x67ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055"), + SafeBlockHash: common.FromHex("0x67ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055"), + FinalizedBlockHash: common.FromHex("0x67ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055"), + } + return &forkchoiceState +} + +func ForkchoiceStateV1_HeadBlockHashLengthErrors(t *TestEnv) { + forkchoiceState := ForkchoiceStateBytesGenesis(t) + forkchoiceState.HeadBlockHash = common.FromHex("0x0067ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + prefix := t.TestEngine.TestEngineForkchoiceUpdatedBytes(forkchoiceState, nil) + prefix.ExpectError() + forkchoiceState.HeadBlockHash = common.FromHex("0x0167ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + long := t.TestEngine.TestEngineForkchoiceUpdatedBytes(forkchoiceState, nil) + long.ExpectError() + forkchoiceState.HeadBlockHash = common.FromHex("0xead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + short := t.TestEngine.TestEngineForkchoiceUpdatedBytes(forkchoiceState, nil) + short.ExpectError() +} + +func ForkchoiceStateV1_SafeBlockHashLengthErrors(t *TestEnv) { + forkchoiceState := ForkchoiceStateBytesGenesis(t) + forkchoiceState.SafeBlockHash = common.FromHex("0x0067ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + prefix := t.TestEngine.TestEngineForkchoiceUpdatedBytes(forkchoiceState, nil) + prefix.ExpectError() + forkchoiceState.SafeBlockHash = common.FromHex("0x0167ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + long := t.TestEngine.TestEngineForkchoiceUpdatedBytes(forkchoiceState, nil) + long.ExpectError() + forkchoiceState.SafeBlockHash = common.FromHex("0xead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + short := t.TestEngine.TestEngineForkchoiceUpdatedBytes(forkchoiceState, nil) + short.ExpectError() +} + +func ForkchoiceStateV1_FinalizedBlockHashLengthErrors(t *TestEnv) { + forkchoiceState := ForkchoiceStateBytesGenesis(t) + forkchoiceState.FinalizedBlockHash = common.FromHex("0x0067ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + prefix := t.TestEngine.TestEngineForkchoiceUpdatedBytes(forkchoiceState, nil) + prefix.ExpectError() + forkchoiceState.FinalizedBlockHash = common.FromHex("0x0167ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + long := t.TestEngine.TestEngineForkchoiceUpdatedBytes(forkchoiceState, nil) + long.ExpectError() + forkchoiceState.FinalizedBlockHash = common.FromHex("0xead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055") + short := t.TestEngine.TestEngineForkchoiceUpdatedBytes(forkchoiceState, nil) + short.ExpectError() +} + +func PayloadAttributesBytesGenesis(t *TestEnv) *PayloadAttributesBytes{ + payloadAttrbutes := PayloadAttributesBytes{ + Timestamp: 1, + PrevRandao: common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000"), + SuggestedFeeRecipient: common.FromHex("0x0000000000000000000000000000000000000000"), + } + return &payloadAttrbutes +} + +func PayloadAttributesV1_PrevRandaoLengthErrors(t *TestEnv) { + payloadAttrbutes := PayloadAttributesBytesGenesis(t) + payloadAttrbutes.PrevRandao = common.FromHex("0x001000000000000000000000000000000000000000000000000000000000000000"); + prefix := t.TestEngine.TestEngineForkchoiceUpdatedBytes(ForkchoiceStateBytesGenesis(t),payloadAttrbutes) + prefix.ExpectError() + payloadAttrbutes.PrevRandao = common.FromHex("0x10000000000000000000000000000000000000000000000000000000000000000"); + long := t.TestEngine.TestEngineForkchoiceUpdatedBytes(ForkchoiceStateBytesGenesis(t),payloadAttrbutes) + long.ExpectError() + payloadAttrbutes.PrevRandao = common.FromHex("0x00000000000000000000000000000000000000000000000000000000000000"); + short := t.TestEngine.TestEngineForkchoiceUpdatedBytes(ForkchoiceStateBytesGenesis(t),payloadAttrbutes) + short.ExpectError() +} + +func PayloadAttributesV1_SuggestedFeeRecipientLengthErrors(t *TestEnv) { + payloadAttrbutes := PayloadAttributesBytesGenesis(t) + payloadAttrbutes.SuggestedFeeRecipient = common.FromHex("0x001000000000000000000000000000000000000000"); + prefix := t.TestEngine.TestEngineForkchoiceUpdatedBytes(ForkchoiceStateBytesGenesis(t),payloadAttrbutes) + prefix.ExpectError() + payloadAttrbutes.SuggestedFeeRecipient = common.FromHex("0x10000000000000000000000000000000000000000"); + long := t.TestEngine.TestEngineForkchoiceUpdatedBytes(ForkchoiceStateBytesGenesis(t),payloadAttrbutes) + long.ExpectError() + payloadAttrbutes.SuggestedFeeRecipient = common.FromHex("0x00000000000000000000000000000000000000"); + short := t.TestEngine.TestEngineForkchoiceUpdatedBytes(ForkchoiceStateBytesGenesis(t),payloadAttrbutes) + short.ExpectError() +} + +func TransitionConfigurationBytesGenesis(t *TestEnv) *TransitionConfigurationBytes{ + transitionConfiguration := TransitionConfigurationBytes{ + TerminalTotalDifficulty: big.NewInt(196608), + TerminalBlockHash: common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000"), + TerminalBlockNumber: 0, + } + return &transitionConfiguration +} + +func TransitionConfigurationV1_CL_TTD_Must_Match_EL_TTD(t *TestEnv) { + transitionConfiguration := TransitionConfigurationBytesGenesis(t) + CLequalTTD := t.TestEngine.TestEngineExchangeTransitionConfigurationBytes(transitionConfiguration) + CLequalTTD.ExpectNoError() + transitionConfiguration.TerminalTotalDifficulty = big.NewInt(196608-1) + CLdecrementTTD := t.TestEngine.TestEngineExchangeTransitionConfigurationBytes(transitionConfiguration) + CLdecrementTTD.ExpectError() + transitionConfiguration.TerminalTotalDifficulty = big.NewInt(196608+1); + CLincrementTTD := t.TestEngine.TestEngineExchangeTransitionConfigurationBytes(transitionConfiguration) + CLincrementTTD.ExpectError() +} + +func TransitionConfigurationV1_TerminalBlockNumberNotZero(t *TestEnv) { + transitionConfiguration := TransitionConfigurationBytesGenesis(t) + transitionConfiguration.TerminalBlockNumber = 1 + r := t.TestEngine.TestEngineExchangeTransitionConfigurationBytes(transitionConfiguration) + r.ExpectError() +} + +func TransitionConfigurationV1_TerminalBlockHashNotZero(t *TestEnv) { + transitionConfiguration := TransitionConfigurationBytesGenesis(t) + transitionConfiguration.TerminalBlockHash = common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000001") + r := t.TestEngine.TestEngineExchangeTransitionConfigurationBytes(transitionConfiguration) + r.ExpectError() +} + +func TransitionConfigurationV1_TerminalBlockHashLengthErrors(t *TestEnv) { + transitionConfiguration := TransitionConfigurationBytesGenesis(t) + transitionConfiguration.TerminalBlockHash = common.FromHex("0x001000000000000000000000000000000000000000000000000000000000000000") + prefix := t.TestEngine.TestEngineExchangeTransitionConfigurationBytes(transitionConfiguration) + prefix.ExpectError() + transitionConfiguration.TerminalBlockHash = common.FromHex("0x10000000000000000000000000000000000000000000000000000000000000000") + long := t.TestEngine.TestEngineExchangeTransitionConfigurationBytes(transitionConfiguration) + long.ExpectError() + transitionConfiguration.TerminalBlockHash = common.FromHex("0x00000000000000000000000000000000000000000000000000000000000000") + short := t.TestEngine.TestEngineExchangeTransitionConfigurationBytes(transitionConfiguration) + short.ExpectError() +} diff --git a/simulators/ethereum/engine/gen_blockparamsBytes.go b/simulators/ethereum/engine/gen_blockparamsBytes.go new file mode 100644 index 0000000000..e25dbacfb8 --- /dev/null +++ b/simulators/ethereum/engine/gen_blockparamsBytes.go @@ -0,0 +1,52 @@ +// Code generated by github.com/fjl/gencodec. DO NOT EDIT. + +package main + +import ( + "encoding/json" + "errors" + + "github.com/ethereum/go-ethereum/common/hexutil" +) + +var _ = (*payloadAttributesMarshalingBytes)(nil) + +// MarshalJSON marshals as JSON. +func (p PayloadAttributesBytes) MarshalJSON() ([]byte, error) { + type PayloadAttributesBytes struct { + Timestamp hexutil.Uint64 `json:"timestamp" gencodec:"required"` + PrevRandao hexutil.Bytes `json:"prevRandao" gencodec:"required"` + SuggestedFeeRecipient hexutil.Bytes `json:"suggestedFeeRecipient" gencodec:"required"` + } + var enc PayloadAttributesBytes + enc.Timestamp = hexutil.Uint64(p.Timestamp) + enc.PrevRandao = p.PrevRandao + enc.SuggestedFeeRecipient = p.SuggestedFeeRecipient + return json.Marshal(&enc) +} + +// UnmarshalJSON unmarshals from JSON. +func (p *PayloadAttributesBytes) UnmarshalJSON(input []byte) error { + type PayloadAttributesBytes struct { + Timestamp *hexutil.Uint64 `json:"timestamp" gencodec:"required"` + PrevRandao *hexutil.Bytes `json:"prevRandao" gencodec:"required"` + SuggestedFeeRecipient *hexutil.Bytes `json:"suggestedFeeRecipient" gencodec:"required"` + } + var dec PayloadAttributesBytes + if err := json.Unmarshal(input, &dec); err != nil { + return err + } + if dec.Timestamp == nil { + return errors.New("missing required field 'timestamp' for PayloadAttributesBytes") + } + p.Timestamp = uint64(*dec.Timestamp) + if dec.PrevRandao == nil { + return errors.New("missing required field 'prevRandao' for PayloadAttributesBytes") + } + p.PrevRandao = *dec.PrevRandao + if dec.SuggestedFeeRecipient == nil { + return errors.New("missing required field 'suggestedFeeRecipient' for PayloadAttributesBytes") + } + p.SuggestedFeeRecipient = *dec.SuggestedFeeRecipient + return nil +} diff --git a/simulators/ethereum/engine/gen_edBytes.go b/simulators/ethereum/engine/gen_edBytes.go new file mode 100644 index 0000000000..6092e9d737 --- /dev/null +++ b/simulators/ethereum/engine/gen_edBytes.go @@ -0,0 +1,138 @@ +// Code generated by github.com/fjl/gencodec. DO NOT EDIT. + +package main + +import ( + "encoding/json" + "errors" + "math/big" + + "github.com/ethereum/go-ethereum/common/hexutil" +) + +var _ = (*executableDataMarshalingByteType)(nil) + +// MarshalJSON marshals as JSON. +func (e ExecutableDataByteType) MarshalJSON() ([]byte, error) { + type ExecutableDataByteType struct { + ParentHash hexutil.Bytes `json:"parentHash" gencodec:"required"` + FeeRecipient hexutil.Bytes `json:"feeRecipient" gencodec:"required"` + StateRoot hexutil.Bytes `json:"stateRoot" gencodec:"required"` + ReceiptsRoot hexutil.Bytes `json:"receiptsRoot" gencodec:"required"` + LogsBloom hexutil.Bytes `json:"logsBloom" gencodec:"required"` + PrevRandao hexutil.Bytes `json:"prevRandao" gencodec:"required"` + Number hexutil.Uint64 `json:"blockNumber" gencodec:"required"` + GasLimit hexutil.Uint64 `json:"gasLimit" gencodec:"required"` + GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"` + Timestamp hexutil.Uint64 `json:"timestamp" gencodec:"required"` + ExtraData hexutil.Bytes `json:"extraData" gencodec:"required"` + BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"` + BlockHash hexutil.Bytes `json:"blockHash" gencodec:"required"` + Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"` + } + var enc ExecutableDataByteType + enc.ParentHash = e.ParentHash + enc.FeeRecipient = e.FeeRecipient + enc.StateRoot = e.StateRoot + enc.ReceiptsRoot = e.ReceiptsRoot + enc.LogsBloom = e.LogsBloom + enc.PrevRandao = e.PrevRandao + enc.Number = hexutil.Uint64(e.Number) + enc.GasLimit = hexutil.Uint64(e.GasLimit) + enc.GasUsed = hexutil.Uint64(e.GasUsed) + enc.Timestamp = hexutil.Uint64(e.Timestamp) + enc.ExtraData = e.ExtraData + enc.BaseFeePerGas = (*hexutil.Big)(e.BaseFeePerGas) + enc.BlockHash = e.BlockHash + if e.Transactions != nil { + enc.Transactions = make([]hexutil.Bytes, len(e.Transactions)) + for k, v := range e.Transactions { + enc.Transactions[k] = v + } + } + return json.Marshal(&enc) +} + +// UnmarshalJSON unmarshals from JSON. +func (e *ExecutableDataByteType) UnmarshalJSON(input []byte) error { + type ExecutableDataByteType struct { + ParentHash *hexutil.Bytes `json:"parentHash" gencodec:"required"` + FeeRecipient *hexutil.Bytes `json:"feeRecipient" gencodec:"required"` + StateRoot *hexutil.Bytes `json:"stateRoot" gencodec:"required"` + ReceiptsRoot *hexutil.Bytes `json:"receiptsRoot" gencodec:"required"` + LogsBloom *hexutil.Bytes `json:"logsBloom" gencodec:"required"` + PrevRandao *hexutil.Bytes `json:"prevRandao" gencodec:"required"` + Number *hexutil.Uint64 `json:"blockNumber" gencodec:"required"` + GasLimit *hexutil.Uint64 `json:"gasLimit" gencodec:"required"` + GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"` + Timestamp *hexutil.Uint64 `json:"timestamp" gencodec:"required"` + ExtraData *hexutil.Bytes `json:"extraData" gencodec:"required"` + BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"` + BlockHash *hexutil.Bytes `json:"blockHash" gencodec:"required"` + Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"` + } + var dec ExecutableDataByteType + if err := json.Unmarshal(input, &dec); err != nil { + return err + } + if dec.ParentHash == nil { + return errors.New("missing required field 'parentHash' for ExecutableDataByteType") + } + e.ParentHash = *dec.ParentHash + if dec.FeeRecipient == nil { + return errors.New("missing required field 'feeRecipient' for ExecutableDataByteType") + } + e.FeeRecipient = *dec.FeeRecipient + if dec.StateRoot == nil { + return errors.New("missing required field 'stateRoot' for ExecutableDataByteType") + } + e.StateRoot = *dec.StateRoot + if dec.ReceiptsRoot == nil { + return errors.New("missing required field 'receiptsRoot' for ExecutableDataByteType") + } + e.ReceiptsRoot = *dec.ReceiptsRoot + if dec.LogsBloom == nil { + return errors.New("missing required field 'logsBloom' for ExecutableDataByteType") + } + e.LogsBloom = *dec.LogsBloom + if dec.PrevRandao == nil { + return errors.New("missing required field 'prevRandao' for ExecutableDataByteType") + } + e.PrevRandao = *dec.PrevRandao + if dec.Number == nil { + return errors.New("missing required field 'blockNumber' for ExecutableDataByteType") + } + e.Number = uint64(*dec.Number) + if dec.GasLimit == nil { + return errors.New("missing required field 'gasLimit' for ExecutableDataByteType") + } + e.GasLimit = uint64(*dec.GasLimit) + if dec.GasUsed == nil { + return errors.New("missing required field 'gasUsed' for ExecutableDataByteType") + } + e.GasUsed = uint64(*dec.GasUsed) + if dec.Timestamp == nil { + return errors.New("missing required field 'timestamp' for ExecutableDataByteType") + } + e.Timestamp = uint64(*dec.Timestamp) + if dec.ExtraData == nil { + return errors.New("missing required field 'extraData' for ExecutableDataByteType") + } + e.ExtraData = *dec.ExtraData + if dec.BaseFeePerGas == nil { + return errors.New("missing required field 'baseFeePerGas' for ExecutableDataByteType") + } + e.BaseFeePerGas = (*big.Int)(dec.BaseFeePerGas) + if dec.BlockHash == nil { + return errors.New("missing required field 'blockHash' for ExecutableDataByteType") + } + e.BlockHash = *dec.BlockHash + if dec.Transactions == nil { + return errors.New("missing required field 'transactions' for ExecutableDataByteType") + } + e.Transactions = make([][]byte, len(dec.Transactions)) + for k, v := range dec.Transactions { + e.Transactions[k] = v + } + return nil +} diff --git a/simulators/ethereum/engine/gen_transitionconfBytes.go b/simulators/ethereum/engine/gen_transitionconfBytes.go new file mode 100644 index 0000000000..1e57fbbb79 --- /dev/null +++ b/simulators/ethereum/engine/gen_transitionconfBytes.go @@ -0,0 +1,53 @@ +// Code generated by github.com/fjl/gencodec. DO NOT EDIT. + +package main + +import ( + "encoding/json" + "errors" + "math/big" + + "github.com/ethereum/go-ethereum/common/hexutil" +) + +var _ = (*TransitionConfigurationV1MarshalingBytes)(nil) + +// MarshalJSON marshals as JSON. +func (t TransitionConfigurationBytes) MarshalJSON() ([]byte, error) { + type TransitionConfigurationBytes struct { + TerminalTotalDifficulty *hexutil.Big `json:"terminalTotalDifficulty" gencodec:"required"` + TerminalBlockHash hexutil.Bytes `json:"terminalBlockHash" gencodec:"required"` + TerminalBlockNumber hexutil.Uint64 `json:"terminalBlockNumber" gencodec:"required"` + } + var enc TransitionConfigurationBytes + enc.TerminalTotalDifficulty = (*hexutil.Big)(t.TerminalTotalDifficulty) + enc.TerminalBlockHash = t.TerminalBlockHash + enc.TerminalBlockNumber = hexutil.Uint64(t.TerminalBlockNumber) + return json.Marshal(&enc) +} + +// UnmarshalJSON unmarshals from JSON. +func (t *TransitionConfigurationBytes) UnmarshalJSON(input []byte) error { + type TransitionConfigurationBytes struct { + TerminalTotalDifficulty *hexutil.Big `json:"terminalTotalDifficulty" gencodec:"required"` + TerminalBlockHash *hexutil.Bytes `json:"terminalBlockHash" gencodec:"required"` + TerminalBlockNumber *hexutil.Uint64 `json:"terminalBlockNumber" gencodec:"required"` + } + var dec TransitionConfigurationBytes + if err := json.Unmarshal(input, &dec); err != nil { + return err + } + if dec.TerminalTotalDifficulty == nil { + return errors.New("missing required field 'terminalTotalDifficulty' for TransitionConfigurationBytes") + } + t.TerminalTotalDifficulty = (*big.Int)(dec.TerminalTotalDifficulty) + if dec.TerminalBlockHash == nil { + return errors.New("missing required field 'terminalBlockHash' for TransitionConfigurationBytes") + } + t.TerminalBlockHash = *dec.TerminalBlockHash + if dec.TerminalBlockNumber == nil { + return errors.New("missing required field 'terminalBlockNumber' for TransitionConfigurationBytes") + } + t.TerminalBlockNumber = uint64(*dec.TerminalBlockNumber) + return nil +} diff --git a/simulators/ethereum/engine/teststruct.go b/simulators/ethereum/engine/teststruct.go index ee12dabb52..bd3e258937 100644 --- a/simulators/ethereum/engine/teststruct.go +++ b/simulators/ethereum/engine/teststruct.go @@ -40,6 +40,15 @@ func (tec *TestEngineClient) TestEngineForkchoiceUpdatedV1(fcState *ForkchoiceSt } } +func (tec *TestEngineClient) TestEngineForkchoiceUpdatedBytes(fcState *ForkchoiceStateBytes, pAttributes *PayloadAttributesBytes) *ForkchoiceResponseExpectObject { + resp, err := tec.EngineClient.EngineForkchoiceUpdatedBytes(tec.EngineClient.Ctx(), fcState, pAttributes) + return &ForkchoiceResponseExpectObject{ + TestEnv: tec.TestEnv, + Response: resp, + Error: err, + } +} + func (exp *ForkchoiceResponseExpectObject) ExpectNoError() { if exp.Error != nil { exp.Fatalf("FAIL (%s): Unexpected error on EngineForkchoiceUpdatedV1: %v, expected=", exp.TestName, exp.Error) @@ -108,6 +117,15 @@ func (tec *TestEngineClient) TestEngineNewPayloadV1(payload *ExecutableDataV1) * } } +func (tec *TestEngineClient) TestEngineNewPayloadByteType(payload *ExecutableDataByteType) *NewPayloadResponseExpectObject { + status, err := tec.EngineClient.EngineNewPayloadByteType(tec.EngineClient.Ctx(), payload) + return &NewPayloadResponseExpectObject{ + TestEnv: tec.TestEnv, + Status: status, + Error: err, + } +} + func (exp *NewPayloadResponseExpectObject) ExpectNoError() { if exp.Error != nil { exp.Fatalf("FAIL (%s): Expected no error on EngineNewPayloadV1: error=%v", exp.TestName, exp.Error) @@ -207,6 +225,61 @@ func (exp *GetPayloadResponseExpectObject) ExpectTimestamp(expectedTimestamp uin } } +// TransitionConfigurationV1 +type ExchangeTransitionConfigurationResponseExpectObject struct { + *TestEnv + Response TransitionConfigurationV1 + Error error +} + +func (tec *TestEngineClient) TestEngineExchangeTransitionConfigurationV1(payload *TransitionConfigurationV1) *ExchangeTransitionConfigurationResponseExpectObject { + response, err := tec.EngineClient.EngineExchangeTransitionConfigurationV1(tec.EngineClient.Ctx(), payload) + return &ExchangeTransitionConfigurationResponseExpectObject{ + TestEnv: tec.TestEnv, + Response: response, + Error: err, + } +} + +type ExchangeTransitionConfigurationBytesResponseExpectObject struct { + *TestEnv + Response TransitionConfigurationBytes + Error error +} + +func (exp *ExchangeTransitionConfigurationResponseExpectObject) ExpectNoError() { + if exp.Error != nil { + exp.Fatalf("FAIL (%s): Expected no error on TransitionConfigurationV1: error=%v", exp.TestName, exp.Error) + } +} + +func (exp *ExchangeTransitionConfigurationResponseExpectObject) ExpectError() { + if exp.Error == nil { + exp.Fatalf("FAIL (%s): Expected error on TransitionConfigurationV1: payload=%v", exp.TestName, exp.Response) + } +} + +func (tec *TestEngineClient) TestEngineExchangeTransitionConfigurationBytes(payload *TransitionConfigurationBytes) *ExchangeTransitionConfigurationBytesResponseExpectObject { + response, err := tec.EngineClient.EngineExchangeTransitionConfigurationBytes(tec.EngineClient.Ctx(), payload) + return &ExchangeTransitionConfigurationBytesResponseExpectObject{ + TestEnv: tec.TestEnv, + Response: response, + Error: err, + } +} + +func (exp *ExchangeTransitionConfigurationBytesResponseExpectObject) ExpectNoError() { + if exp.Error != nil { + exp.Fatalf("FAIL (%s): Expected no error on TransitionConfigurationV1: error=%v", exp.TestName, exp.Error) + } +} + +func (exp *ExchangeTransitionConfigurationBytesResponseExpectObject) ExpectError() { + if exp.Error == nil { + exp.Fatalf("FAIL (%s): Expected error on TransitionConfigurationV1: payload=%v", exp.TestName, exp.Response) + } +} + // Test Eth JSON-RPC Helper Structs type TestEthClient struct { *TestEnv From 4452ced1cd39908c98dc20ecd69a32f911e4d73f Mon Sep 17 00:00:00 2001 From: ~MarcusWentz Date: Thu, 2 Jun 2022 13:14:04 -0400 Subject: [PATCH 2/2] teststruct ExTransConfig simplified --- .../ethereum/engine/gen_transitionconf.go | 54 ------------------- simulators/ethereum/engine/teststruct.go | 39 +++----------- 2 files changed, 6 insertions(+), 87 deletions(-) delete mode 100644 simulators/ethereum/engine/gen_transitionconf.go diff --git a/simulators/ethereum/engine/gen_transitionconf.go b/simulators/ethereum/engine/gen_transitionconf.go deleted file mode 100644 index e13ac73eea..0000000000 --- a/simulators/ethereum/engine/gen_transitionconf.go +++ /dev/null @@ -1,54 +0,0 @@ -// Code generated by github.com/fjl/gencodec. DO NOT EDIT. - -package main - -import ( - "encoding/json" - "errors" - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" -) - -var _ = (*TransitionConfigurationV1Marshaling)(nil) - -// MarshalJSON marshals as JSON. -func (t TransitionConfigurationV1) MarshalJSON() ([]byte, error) { - type TransitionConfigurationV1 struct { - TerminalTotalDifficulty *hexutil.Big `json:"terminalTotalDifficulty" gencodec:"required"` - TerminalBlockHash *common.Hash `json:"terminalBlockHash" gencodec:"required"` - TerminalBlockNumber hexutil.Uint64 `json:"terminalBlockNumber" gencodec:"required"` - } - var enc TransitionConfigurationV1 - enc.TerminalTotalDifficulty = (*hexutil.Big)(t.TerminalTotalDifficulty) - enc.TerminalBlockHash = t.TerminalBlockHash - enc.TerminalBlockNumber = hexutil.Uint64(t.TerminalBlockNumber) - return json.Marshal(&enc) -} - -// UnmarshalJSON unmarshals from JSON. -func (t *TransitionConfigurationV1) UnmarshalJSON(input []byte) error { - type TransitionConfigurationV1 struct { - TerminalTotalDifficulty *hexutil.Big `json:"terminalTotalDifficulty" gencodec:"required"` - TerminalBlockHash *common.Hash `json:"terminalBlockHash" gencodec:"required"` - TerminalBlockNumber *hexutil.Uint64 `json:"terminalBlockNumber" gencodec:"required"` - } - var dec TransitionConfigurationV1 - if err := json.Unmarshal(input, &dec); err != nil { - return err - } - if dec.TerminalTotalDifficulty == nil { - return errors.New("missing required field 'terminalTotalDifficulty' for TransitionConfigurationV1") - } - t.TerminalTotalDifficulty = (*big.Int)(dec.TerminalTotalDifficulty) - if dec.TerminalBlockHash == nil { - return errors.New("missing required field 'terminalBlockHash' for TransitionConfigurationV1") - } - t.TerminalBlockHash = dec.TerminalBlockHash - if dec.TerminalBlockNumber == nil { - return errors.New("missing required field 'terminalBlockNumber' for TransitionConfigurationV1") - } - t.TerminalBlockNumber = uint64(*dec.TerminalBlockNumber) - return nil -} diff --git a/simulators/ethereum/engine/teststruct.go b/simulators/ethereum/engine/teststruct.go index bd3e258937..3c8ad36bc1 100644 --- a/simulators/ethereum/engine/teststruct.go +++ b/simulators/ethereum/engine/teststruct.go @@ -225,56 +225,29 @@ func (exp *GetPayloadResponseExpectObject) ExpectTimestamp(expectedTimestamp uin } } -// TransitionConfigurationV1 -type ExchangeTransitionConfigurationResponseExpectObject struct { - *TestEnv - Response TransitionConfigurationV1 - Error error -} - -func (tec *TestEngineClient) TestEngineExchangeTransitionConfigurationV1(payload *TransitionConfigurationV1) *ExchangeTransitionConfigurationResponseExpectObject { - response, err := tec.EngineClient.EngineExchangeTransitionConfigurationV1(tec.EngineClient.Ctx(), payload) - return &ExchangeTransitionConfigurationResponseExpectObject{ - TestEnv: tec.TestEnv, - Response: response, - Error: err, - } -} - -type ExchangeTransitionConfigurationBytesResponseExpectObject struct { +// ExchangeTransitionConfigurationV1 in bytes format. +type ExTransConfigResponseExpectObject struct { *TestEnv Response TransitionConfigurationBytes Error error } -func (exp *ExchangeTransitionConfigurationResponseExpectObject) ExpectNoError() { - if exp.Error != nil { - exp.Fatalf("FAIL (%s): Expected no error on TransitionConfigurationV1: error=%v", exp.TestName, exp.Error) - } -} - -func (exp *ExchangeTransitionConfigurationResponseExpectObject) ExpectError() { - if exp.Error == nil { - exp.Fatalf("FAIL (%s): Expected error on TransitionConfigurationV1: payload=%v", exp.TestName, exp.Response) - } -} - -func (tec *TestEngineClient) TestEngineExchangeTransitionConfigurationBytes(payload *TransitionConfigurationBytes) *ExchangeTransitionConfigurationBytesResponseExpectObject { +func (tec *TestEngineClient) TestEngineExchangeTransitionConfigurationBytes(payload *TransitionConfigurationBytes) *ExTransConfigResponseExpectObject { response, err := tec.EngineClient.EngineExchangeTransitionConfigurationBytes(tec.EngineClient.Ctx(), payload) - return &ExchangeTransitionConfigurationBytesResponseExpectObject{ + return &ExTransConfigResponseExpectObject{ TestEnv: tec.TestEnv, Response: response, Error: err, } } -func (exp *ExchangeTransitionConfigurationBytesResponseExpectObject) ExpectNoError() { +func (exp *ExTransConfigResponseExpectObject) ExpectNoError() { if exp.Error != nil { exp.Fatalf("FAIL (%s): Expected no error on TransitionConfigurationV1: error=%v", exp.TestName, exp.Error) } } -func (exp *ExchangeTransitionConfigurationBytesResponseExpectObject) ExpectError() { +func (exp *ExTransConfigResponseExpectObject) ExpectError() { if exp.Error == nil { exp.Fatalf("FAIL (%s): Expected error on TransitionConfigurationV1: payload=%v", exp.TestName, exp.Response) }