Documentation ¶
Index ¶
- Constants
- Variables
- func AcceptedOnAllPeers(blockID string, peers []*framework.Node) bool
- func AddressUnspentOutputs(t *testing.T, node *framework.Node, address devnetvm.Address, ...) []jsonmodels.WalletOutput
- func Balance(t *testing.T, node *framework.Node, address devnetvm.Address, ...) uint64
- func BootstrapNetwork(t *testing.T, n *framework.Network)
- func Bootstrapped(t *testing.T, node *framework.Node) bool
- func CommonSnapshotConfigFunc(t *testing.T, snapshotOptions *snapshotcreator.Options, ...) framework.CfgAlterFunc
- func Context(ctx context.Context, t *testing.T) (context.Context, context.CancelFunc)
- func CreateTransactionFromOutputs(t *testing.T, manaPledgeID identity.ID, targetAddresses []devnetvm.Address, ...) *devnetvm.Transaction
- func GetIdentSeed(t *testing.T, snapshotOptions *snapshotcreator.Options, peerIndex int) []byte
- func Mana(t *testing.T, node *framework.Node) jsonmodels.Mana
- func OutputIndex(transaction *devnetvm.Transaction, address devnetvm.Address) int
- func RequireBalancesEqual(t *testing.T, nodes []*framework.Node, ...)
- func RequireBlocksAvailable(t *testing.T, nodes []*framework.Node, blockIDs map[string]DataBlockSent, ...)
- func RequireBlocksEqual(t *testing.T, nodes []*framework.Node, blocksByID map[string]DataBlockSent, ...)
- func RequireBlocksOrphaned(t *testing.T, nodes []*framework.Node, blockIDs map[string]DataBlockSent, ...)
- func RequireConfirmationStateEqual(t *testing.T, nodes framework.Nodes, expectedStates ExpectedTxsStates, ...)
- func RequireTransactionsEqual(t *testing.T, nodes []*framework.Node, ...)
- func SendDataBlocks(t *testing.T, peers []*framework.Node, numBlocks int, ...) map[string]DataBlockSent
- func SendDataBlocksWithDelay(t *testing.T, peers []*framework.Node, numBlocks int, delay time.Duration, ...) (result map[string]DataBlockSent)
- func SendTransaction(t *testing.T, from *framework.Node, to *framework.Node, color devnetvm.Color, ...) (string, error)
- func ShutdownNetwork(ctx context.Context, t *testing.T, n interface{ ... })
- func Synced(t *testing.T, node *framework.Node) bool
- func True() *bool
- func TryAcceptBlock(t *testing.T, peers []*framework.Node, blockID string, waitFor time.Duration, ...)
- type DataBlockSent
- type ExpectedAddrsBalances
- type ExpectedState
- type ExpectedTransaction
- type ExpectedTxsStates
- type TransactionConfig
Constants ¶
const ( // Timeout denotes the default condition polling timout duration. Timeout = 1 * time.Minute // Tick denotes the default condition polling tick time. Tick = 500 * time.Millisecond )
Variables ¶
var ConsensusSnapshotOptions = []options.Option[snapshotcreator.Options]{ snapshotcreator.WithFilePath("/assets/dynamic_snapshots/consensus_snapshot.bin"), snapshotcreator.WithGenesisTokenAmount(800_000), snapshotcreator.WithPeersSeedBase58([]string{ "Bk69VaYsRuiAaKn8hK6KxUj45X5dED3ueRtxfYnsh4Q8", "HUH4rmxUxMZBBtHJ4QM5Ts6s8DP3HnFpChejntnCxto2", "CmFVE14Yh9rqn2FrXD8s7ybRoRN5mUnqQxLAuD5HF2em", "DuJuWE3hisFrFK1HmrXkd9FSsNNWbw58JcQnKdBn6TdN", }), snapshotcreator.WithPeersAmountsPledged([]uint64{1_600_000, 800_000, 800_000, 800_000, 800_000}), snapshotcreator.WithInitialAttestationsBase58([]string{"3kwsHfLDb7ifuxLbyMZneXq3s5heRWnXKKGPAARJDaUE"}), }
var EqualSnapshotOptions = []options.Option[snapshotcreator.Options]{ snapshotcreator.WithFilePath("/assets/dynamic_snapshots/equal_snapshot.bin"), snapshotcreator.WithGenesisTokenAmount(2_500_000_000_000_000), snapshotcreator.WithPeersSeedBase58([]string{ "GtKSdqanb4mokUBjAf9JZmsSqWzWjzzw57mRR56LjfBL", "CmFVE14Yh9rqn2FrXD8s7ybRoRN5mUnqQxLAuD5HF2em", "DuJuWE3hisFrFK1HmrXkd9FSsNNWbw58JcQnKdBn6TdN", "3YX6e7AL28hHihZewKdq6CMkEYVsTJBLgRiprUNiNq5E", }), snapshotcreator.WithPeersAmountsPledged([]uint64{2_500_000_000_000_000, 2_500_000_000_000_000, 2_500_000_000_000_000, 2_500_000_000_000_000}), snapshotcreator.WithInitialAttestationsBase58([]string{"B45CgJeL9rfigCNXdkReZoVmK4RJqw4E81zYuETA4zJC"}), }
EqualSnapshotOptions defines snapshot options for equal test scenario.
var OrphanageSnapshotOptions = []options.Option[snapshotcreator.Options]{ snapshotcreator.WithFilePath("/assets/dynamic_snapshots/orphanage_snapshot.bin"), snapshotcreator.WithGenesisTokenAmount(0), snapshotcreator.WithPeersSeedBase58([]string{ "3YX6e7AL28hHihZewKdq6CMkEYVsTJBLgRiprUNiNq5E", "GtKSdqanb4mokUBjAf9JZmsSqWzWjzzw57mRR56LjfBL", "CmFVE14Yh9rqn2FrXD8s7ybRoRN5mUnqQxLAuD5HF2em", "DuJuWE3hisFrFK1HmrXkd9FSsNNWbw58JcQnKdBn6TdN", }), snapshotcreator.WithPeersAmountsPledged([]uint64{2_500_000_000_000_000, 2_500_000_000_000_000, 2_500_000_000_000_000, 10}), }
OrphanageSnapshotOptions defines snapshot options for orphanage test scenario.
Functions ¶
func AcceptedOnAllPeers ¶
AcceptedOnAllPeers checks if the blk is accepted on all supplied peers.
func AddressUnspentOutputs ¶
func AddressUnspentOutputs(t *testing.T, node *framework.Node, address devnetvm.Address, numOfExpectedOuts int) []jsonmodels.WalletOutput
AddressUnspentOutputs returns the unspent outputs on address.
func Balance ¶
func Balance(t *testing.T, node *framework.Node, address devnetvm.Address, color devnetvm.Color) uint64
Balance returns the total balance of color at address.
func Bootstrapped ¶
Bootstrapped returns whether node is bootstrapped.
func CommonSnapshotConfigFunc ¶
func CommonSnapshotConfigFunc(t *testing.T, snapshotOptions *snapshotcreator.Options, cfgFunc ...framework.CfgAlterFunc) framework.CfgAlterFunc
CommonSnapshotConfigFunc returns a peer configuration altering function that uses the specified Snapshot information for all peers. If a cfgFunc is provided, further manipulation of the base config for every peer is possible.
func CreateTransactionFromOutputs ¶
func CreateTransactionFromOutputs(t *testing.T, manaPledgeID identity.ID, targetAddresses []devnetvm.Address, keyPairs map[string]*ed25519.KeyPair, utxos ...devnetvm.Output) *devnetvm.Transaction
CreateTransactionFromOutputs takes the given utxos inputs and create a transaction that spreads the total input balance across the targetAddresses. In order to correctly sign we have a keyPair map that maps a given address to its public key. Access and Consensus Mana is pledged to the node we specify.
func GetIdentSeed ¶
GetIdentSeed returns decoded seed bytes for the supplied SnapshotInfo and peer index
func OutputIndex ¶
func OutputIndex(transaction *devnetvm.Transaction, address devnetvm.Address) int
OutputIndex returns the index of the first output to address.
func RequireBalancesEqual ¶
func RequireBalancesEqual(t *testing.T, nodes []*framework.Node, balancesByAddress map[string]map[devnetvm.Color]uint64)
RequireBalancesEqual asserts that all nodes report the balances as specified in balancesByAddress.
func RequireBlocksAvailable ¶
func RequireBlocksAvailable(t *testing.T, nodes []*framework.Node, blockIDs map[string]DataBlockSent, waitFor time.Duration, tick time.Duration, accepted ...bool)
RequireBlocksAvailable asserts that all nodes have received BlockIDs in waitFor time, periodically checking each tick. Optionally, a ConfirmationState can be specified, which then requires the blocks to reach this ConfirmationState.
func RequireBlocksEqual ¶
func RequireBlocksEqual(t *testing.T, nodes []*framework.Node, blocksByID map[string]DataBlockSent, waitFor time.Duration, tick time.Duration)
RequireBlocksEqual asserts that all nodes return the correct data blocks as specified in blocksByID.
func RequireBlocksOrphaned ¶
func RequireBlocksOrphaned(t *testing.T, nodes []*framework.Node, blockIDs map[string]DataBlockSent, waitFor time.Duration, tick time.Duration)
RequireBlocksOrphaned asserts that all nodes have received BlockIDs and marked them as orphaned in waitFor time, periodically checking each tick.
func RequireConfirmationStateEqual ¶
func RequireConfirmationStateEqual(t *testing.T, nodes framework.Nodes, expectedStates ExpectedTxsStates, waitFor time.Duration, tick time.Duration)
RequireConfirmationStateEqual asserts that all nodes have received the transaction and have correct expectedStates in waitFor time, periodically checking each tick.
func RequireTransactionsEqual ¶
func RequireTransactionsEqual(t *testing.T, nodes []*framework.Node, transactionsByID map[string]*ExpectedTransaction)
RequireTransactionsEqual asserts that all nodes return the correct transactions as specified in transactionsByID.
func SendDataBlocks ¶
func SendDataBlocks(t *testing.T, peers []*framework.Node, numBlocks int, idsMap ...map[string]DataBlockSent) map[string]DataBlockSent
SendDataBlocks sends a total of numBlocks data blocks and saves the sent block to a map. It chooses the peers to send the blocks from in a round-robin fashion.
func SendDataBlocksWithDelay ¶
func SendDataBlocksWithDelay(t *testing.T, peers []*framework.Node, numBlocks int, delay time.Duration, idsMap ...map[string]DataBlockSent) (result map[string]DataBlockSent)
SendDataBlocksWithDelay sends a total of numBlocks data blocks, each after a delay interval, and saves the sent block to a map. It chooses the peers to send the blocks from in a round-robin fashion.
func SendTransaction ¶
func SendTransaction(t *testing.T, from *framework.Node, to *framework.Node, color devnetvm.Color, value uint64, txConfig TransactionConfig, addrBalance ...map[string]map[devnetvm.Color]uint64) (string, error)
SendTransaction sends a transaction of value and color. It returns the transactionID and the error return by PostTransaction. If addrBalance is given the balance mutation are added to that map.
func ShutdownNetwork ¶
func ShutdownNetwork(ctx context.Context, t *testing.T, n interface{ Shutdown(context.Context) error })
ShutdownNetwork shuts down the network and reports errors.
Types ¶
type DataBlockSent ¶
type DataBlockSent struct {
// contains filtered or unexported fields
}
DataBlockSent defines a struct to identify from which issuer a data block was sent.
func SendDataBlock ¶
func SendDataBlock(t *testing.T, node *framework.Node, data []byte, number int) (string, DataBlockSent)
SendDataBlock sends a data block on a given peer and returns the id and a DataBlockSent struct.
func SendFaucetRequest ¶
func SendFaucetRequest(t *testing.T, node *framework.Node, addr devnetvm.Address, manaPledgeIDs ...string) (string, DataBlockSent)
SendFaucetRequest sends a data block on a given peer and returns the id and a DataBlockSent struct. By default, it pledges mana to the peer making the request.
type ExpectedAddrsBalances ¶
ExpectedAddrsBalances is a map of base58 encoded addresses to the balances they should hold.
type ExpectedState ¶
type ExpectedState struct { // The optional confirmation state to check against. ConfirmationState confirmation.State // The optional solid state to check against. Solid *bool }
ExpectedState is an expected state. All fields are optional.
type ExpectedTransaction ¶
type ExpectedTransaction struct { Inputs []*jsonmodels.Input // The optional outputs to check against. Outputs []*jsonmodels.Output // The optional unlock blocks to check against. UnlockBlocks []*jsonmodels.UnlockBlock }
ExpectedTransaction defines the expected data of a transaction. All fields are optional.
type ExpectedTxsStates ¶
type ExpectedTxsStates map[string]ExpectedState
ExpectedTxsStates is a map of base58 encoded transactionIDs to their ExpectedState(s).