Documentation
¶
Index ¶
- Constants
- Variables
- func RunChainReaderInterfaceTests[T TestingT[T]](t T, tester ChainReaderInterfaceTester[T])
- func RunCodecInterfaceFuzzTests(f *testing.F, tester CodecInterfaceTester)
- func RunCodecInterfaceTests(t *testing.T, tester CodecInterfaceTester)
- func RunCodecWithStrictArgsInterfaceTest(t *testing.T, tester CodecInterfaceTester)
- type BasicTester
- type BatchCallEntry
- type ChainReaderInterfaceTester
- type CodecInterfaceTester
- type ContractBatchEntry
- type EncodeRequest
- type ExpectedGetLatestValueArgs
- type FilterEventParams
- type InnerTestStruct
- type LatestParams
- type MidLevelTestStruct
- type ReadEntry
- type TestStruct
- type TestStructMissingField
- type TestStructWithExtraField
- type TestingT
Constants ¶
View Source
const ( AnyValueToReadWithoutAnArgument = uint64(3) AnyDifferentValueToReadWithoutAnArgument = uint64(1990) MethodTakingLatestParamsReturningTestStruct = "GetLatestValues" MethodReturningUint64 = "GetPrimitiveValue" MethodReturningAlterableUint64 = "GetAlterablePrimitiveValue" MethodReturningUint64Slice = "GetSliceValue" MethodReturningSeenStruct = "GetSeenStruct" EventName = "SomeEvent" EventWithFilterName = "SomeEventToFilter" AnyContractName = "TestContract" AnySecondContractName = "Not" + AnyContractName )
View Source
const ( TestItemType = "TestItem" TestItemSliceType = "TestItemSliceType" TestItemArray1Type = "TestItemArray1Type" TestItemArray2Type = "TestItemArray2Type" TestItemWithConfigExtra = "TestItemWithConfigExtra" NilType = "NilType" )
View Source
const AnyExtraValue = 3
Variables ¶
View Source
var AnySliceToReadWithoutAnArgument = []uint64{3, 4}
Functions ¶
func RunChainReaderInterfaceTests ¶
func RunChainReaderInterfaceTests[T TestingT[T]](t T, tester ChainReaderInterfaceTester[T])
func RunCodecInterfaceFuzzTests ¶
func RunCodecInterfaceFuzzTests(f *testing.F, tester CodecInterfaceTester)
func RunCodecInterfaceTests ¶
func RunCodecInterfaceTests(t *testing.T, tester CodecInterfaceTester)
func RunCodecWithStrictArgsInterfaceTest ¶
func RunCodecWithStrictArgsInterfaceTest(t *testing.T, tester CodecInterfaceTester)
RunCodecWithStrictArgsInterfaceTest is meant to be used by codecs that don't pad They can assure that the right argument size is verified. Padding makes that harder/impossible to verify for come codecs. However, the extra verification is nice to have when possible.
Types ¶
type BasicTester ¶
type BatchCallEntry ¶
type BatchCallEntry map[string]ContractBatchEntry
type ChainReaderInterfaceTester ¶
type ChainReaderInterfaceTester[T TestingT[T]] interface { BasicTester[T] GetChainReader(t T) types.ContractReader // SetTestStructLatestValue is expected to return the same bound contract and method in the same test // Any setup required for this should be done in Setup. // The contract should take a LatestParams as the params and return the nth TestStruct set SetTestStructLatestValue(t T, testStruct *TestStruct) // SetUintLatestValue is expected to return the same bound contract and method in the same test // Any setup required for this should be done in Setup. // The contract should take a uint64 as the params and returns the same. // forCall is used to attach value to a call, this is useful in chain specific test since in chain agnostic tests we can just use hard coded readName constants. SetUintLatestValue(t T, val uint64, forCall ExpectedGetLatestValueArgs) SetBatchLatestValues(t T, batchCallEntry BatchCallEntry) TriggerEvent(t T, testStruct *TestStruct) GetBindings(t T) []types.BoundContract // GenerateBlocksTillConfidenceLevel raises confidence level to the provided level for a specific read. GenerateBlocksTillConfidenceLevel(t T, contractName, readName string, confidenceLevel primitives.ConfidenceLevel) MaxWaitTimeForEvents() time.Duration }
type CodecInterfaceTester ¶
type CodecInterfaceTester interface {
BasicTester[*testing.T]
EncodeFields(t *testing.T, request *EncodeRequest) []byte
GetCodec(t *testing.T) types.Codec
// IncludeArrayEncodingSizeEnforcement is here in case there's no way to have fixed arrays in the encoded values
IncludeArrayEncodingSizeEnforcement() bool
}
type ContractBatchEntry ¶
type ContractBatchEntry []ReadEntry
type EncodeRequest ¶
type EncodeRequest struct {
TestStructs []TestStruct
ExtraField bool
MissingField bool
TestOn string
}
type ExpectedGetLatestValueArgs ¶
type ExpectedGetLatestValueArgs struct {
ContractName, ReadName string
ConfidenceLevel primitives.ConfidenceLevel
Params, ReturnVal any
}
func (ExpectedGetLatestValueArgs) String ¶
func (e ExpectedGetLatestValueArgs) String() string
type FilterEventParams ¶
type FilterEventParams struct {
Field int32
}
type InnerTestStruct ¶
type LatestParams ¶
type LatestParams struct {
// I should be > 0
I int
}
type MidLevelTestStruct ¶
type MidLevelTestStruct struct {
FixedBytes [2]byte
Inner InnerTestStruct
}
type TestStruct ¶
type TestStruct struct {
Field *int32
DifferentField string
OracleID commontypes.OracleID
OracleIDs [32]commontypes.OracleID
Account []byte
Accounts [][]byte
BigField *big.Int
NestedStruct MidLevelTestStruct
}
func CreateTestStruct ¶
func CreateTestStruct[T any](i int, tester BasicTester[T]) TestStruct
type TestStructMissingField ¶
type TestStructMissingField struct {
DifferentField string
OracleID commontypes.OracleID
OracleIDs [32]commontypes.OracleID
Account []byte
Accounts [][]byte
BigField *big.Int
NestedStruct MidLevelTestStruct
}
type TestStructWithExtraField ¶
type TestStructWithExtraField struct {
TestStruct
ExtraField int
}
Click to show internal directories.
Click to hide internal directories.