testing

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2025 License: Apache-2.0, MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const SQLiteDBConfig = "pdp.db"

Variables

View Source
var ListenerAddress = common.HexToAddress("0x6170dE2b09b404776197485F3dc6c968Ef948506")

this address also doesn't matter

View Source
var RecordKeepAddress = common.HexToAddress("0x6170dE2b09b404776197485F3dc6c968Ef948505")

NB: this address is never sent to during testing so it's value is insignificant. picked a valid address anyways, but can be whatever we want.

Functions

func NewCreateProofSetTransaction

func NewCreateProofSetTransaction(t testing.TB) *types.Transaction

func NewSuccessfulReceipt

func NewSuccessfulReceipt(height int64) *types.Receipt

func Ptr

func Ptr[T any](v T) *T

func RandomBytes

func RandomBytes(t testing.TB, size int) []byte

func RandomCID

func RandomCID(t testing.TB) cid.Cid

Types

type FakeChainClient

type FakeChainClient struct {
	// contains filtered or unexported fields
}

func NewFakeChainClient

func NewFakeChainClient(t testing.TB) *FakeChainClient

func (*FakeChainClient) AdvanceByHeight

func (c *FakeChainClient) AdvanceByHeight(epochs int64) abi.ChainEpoch

AdvanceHeight advances the chain by the specified number of epochs

func (*FakeChainClient) AdvanceChain

func (c *FakeChainClient) AdvanceChain() abi.ChainEpoch

func (*FakeChainClient) ChainHead

func (c *FakeChainClient) ChainHead(ctx context.Context) (*types.TipSet, error)

func (*FakeChainClient) ChainNotify

func (c *FakeChainClient) ChainNotify(ctx context.Context) (<-chan []*api.HeadChange, error)

func (*FakeChainClient) CurrentHeight

func (c *FakeChainClient) CurrentHeight() abi.ChainEpoch

func (*FakeChainClient) StateGetRandomnessDigestFromBeacon

func (c *FakeChainClient) StateGetRandomnessDigestFromBeacon(ctx context.Context, randEpoch abi.ChainEpoch, tsk types.TipSetKey) (abi.Randomness, error)

type Harness

type Harness struct {
	T          testing.TB
	Chain      *FakeChainClient
	EthClient  *MockEthClient
	Contract   *mocks.MockPDP
	Verifier   *mocks.MockPDPVerifier
	Schedule   *mocks.MockPDPProvingSchedule
	DB         *gorm.DB
	ClientAddr common.Address
	// contains filtered or unexported fields
}

func SetupTestDeps

func SetupTestDeps(t testing.TB, ctx context.Context, ctrl *gomock.Controller) (*Harness, *service.PDPService)

func (*Harness) CreateProofSet

func (h *Harness) CreateProofSet(ctx context.Context, svc *service.PDPService, id, challengeWindow, provingPeriod uint64) *models.PDPProofSet

func (*Harness) Require_MessageSendsEth_SendSuccess

func (h *Harness) Require_MessageSendsEth_SendSuccess(reason string, signedTx common.Hash)

Require_MessageSendsEth_SendSuccess asserts a message in MessageSendsEth was sent successfully given a reason and signedTx hash.

func (*Harness) SendCreateProofSet

func (h *Harness) SendCreateProofSet(proofSetID uint64)

func (*Harness) UploadPiece

func (h *Harness) UploadPiece(ctx context.Context, svc *service.PDPService, piece []byte, notify string) *service.PiecePrepareResponse

func (*Harness) WaitFor_MessageWaitsEth_TxSuccess

func (h *Harness) WaitFor_MessageWaitsEth_TxSuccess(signedTx common.Hash)

func (*Harness) WaitFor_PDPProofsetCreate_OK

func (h *Harness) WaitFor_PDPProofsetCreate_OK(signedTx common.Hash)

func (*Harness) WaitFor_PDPProofsetCreate_ProofsetCreated

func (h *Harness) WaitFor_PDPProofsetCreate_ProofsetCreated(signedTx common.Hash)

type MockContractBackendWrapper

type MockContractBackendWrapper struct {
	*mocks.MockContractBackend
}

MockContractBackendWrapper wraps MockContractBackend but excludes the conflicting method

type MockEthClient

MockEthClient combines all mock interfaces for EthClient

func NewMockEthClient

func NewMockEthClient(ctrl *gomock.Controller) *MockEthClient

NewMockEthClient creates a new mock instance that implements all required interfaces

func (*MockEthClient) SuggestGasTipCap

func (m *MockEthClient) SuggestGasTipCap(ctx context.Context) (*big.Int, error)

SuggestGasTipCap delegates to MockSenderETHClient's implementation This overrides the method from MockContractBackend to avoid the conflict

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL