-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ChainWriter to ChainComponents interface tests
- Loading branch information
1 parent
2f4f446
commit 1467436
Showing
14 changed files
with
360 additions
and
204 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
"chainlink": minor | ||
--- | ||
|
||
#internal Added ChainWriter to ChainReader tests |
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
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
39 changes: 39 additions & 0 deletions
39
core/services/relay/evm/chain_writer_historical_wrapper_test.go
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,39 @@ | ||
package evm | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
|
||
commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" | ||
interfacetesttypes "github.com/smartcontractkit/chainlink-common/pkg/types/interfacetests" | ||
primitives "github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives" | ||
) | ||
|
||
// This wrapper is required to enable the ChainReader to access historical data | ||
// Since the geth simulated backend doesn't support historical data, we use this | ||
// thin wrapper. | ||
type ChainWriterHistoricalWrapper struct { | ||
commontypes.ChainWriter | ||
cwh *ClientWithContractHistory | ||
} | ||
|
||
func NewChainWriterHistoricalWrapper(cw commontypes.ChainWriter, cwh *ClientWithContractHistory) *ChainWriterHistoricalWrapper { | ||
return &ChainWriterHistoricalWrapper{ChainWriter: cw, cwh: cwh} | ||
} | ||
|
||
func (cwhw *ChainWriterHistoricalWrapper) SubmitTransaction(ctx context.Context, contractName, method string, args any, transactionID string, toAddress string, meta *commontypes.TxMeta, value *big.Int) error { | ||
if primArgs, ok := args.(interfacetesttypes.PrimitiveArgs); ok { | ||
callArgs := interfacetesttypes.ExpectedGetLatestValueArgs{ | ||
ContractName: contractName, | ||
ReadName: "GetAlterablePrimitiveValue", | ||
ConfidenceLevel: primitives.Unconfirmed, | ||
Params: nil, | ||
ReturnVal: nil, | ||
} | ||
err := cwhw.cwh.SetUintLatestValue(ctx, primArgs.Value, callArgs) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return cwhw.ChainWriter.SubmitTransaction(ctx, contractName, method, args, transactionID, toAddress, meta, value) | ||
} |
Oops, something went wrong.