mock

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AddRights adds a right to the access matrix
	AddRights operation = "addRights"
	// RemoveRights removes a right from the access matrix
	RemoveRights operation = "removeRights"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchTxResponse

type BatchTxResponse map[string]*proto.TxResponse

BatchTxResponse is a batch transaction response

func (BatchTxResponse) TxHasNoError

func (br BatchTxResponse) TxHasNoError(t *testing.T, txID ...string)

TxHasNoError checks if the transaction has no error

type Fee

type Fee struct {
	Currency string   `json:"currency"`
	Fee      *big.Int `json:"fee"`
	Floor    *big.Int `json:"floor"`
	Cap      *big.Int `json:"cap"`
}

Fee struct

type IndustrialMetadata

type IndustrialMetadata struct {
	Name            string          `json:"name"`
	Symbol          string          `json:"symbol"`
	Decimals        uint            `json:"decimals"`
	UnderlyingAsset string          `json:"underlying_asset"` //nolint:tagliatelle
	DeliveryForm    string          `json:"deliveryForm"`
	UnitOfMeasure   string          `json:"unitOfMeasure"`
	TokensForUnit   string          `json:"tokensForUnit"`
	PaymentTerms    string          `json:"paymentTerms"`
	Price           string          `json:"price"`
	Issuer          string          `json:"issuer"`
	Methods         []string        `json:"methods"`
	Groups          []MetadataGroup `json:"groups"`
	Fee             *Fee            `json:"fee"`
	Rates           []*MetadataRate `json:"rates"`
}

IndustrialMetadata struct

type Ledger

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

func NewLedger

func NewLedger(t *testing.T, options ...string) *Ledger

NewLedger creates new ledger

func (*Ledger) GetPending

func (ledger *Ledger) GetPending(token string, txID ...string)

GetPending returns pending transactions

func (*Ledger) GetStub

func (ledger *Ledger) GetStub(name string) *stub.Stub

GetStub returns stub

func (*Ledger) GetStubByKey

func (ledger *Ledger) GetStubByKey(key string) *stub.Stub

GetStubByKey returns stub by key

func (*Ledger) IndustrialMetadata

func (ledger *Ledger) IndustrialMetadata(ch string) *IndustrialMetadata

IndustrialMetadata returns metadata for industrial token

func (*Ledger) Metadata

func (ledger *Ledger) Metadata(ch string) *Metadata

Metadata returns metadata

func (*Ledger) NewCC

func (ledger *Ledger) NewCC(
	name string,
	bci core.BaseContractInterface,
	config string,
	opts ...core.ChaincodeOption,
) string

func (*Ledger) NewCCArgsArr

func (ledger *Ledger) NewCCArgsArr(
	name string,
	bci core.BaseContractInterface,
	initArgs []string,
	opts ...core.ChaincodeOption,
) string

NewCCArgsArr Deprecated: added only for backward compatibility.

func (*Ledger) NewMultisigWallet

func (ledger *Ledger) NewMultisigWallet(n int) *Multisig

NewMultisigWallet creates new multisig wallet

func (*Ledger) NewWallet

func (ledger *Ledger) NewWallet() *Wallet

NewWallet creates new wallet

func (*Ledger) NewWalletFromHexKey

func (ledger *Ledger) NewWalletFromHexKey(key string) *Wallet

NewWalletFromHexKey creates new wallet from hex key

func (*Ledger) NewWalletFromKey

func (ledger *Ledger) NewWalletFromKey(key string) *Wallet

NewWalletFromKey creates new wallet from key

func (*Ledger) SetACL

func (ledger *Ledger) SetACL(aclStub *stub.Stub)

SetACL sets acl stub

func (*Ledger) UpdateStubTxID

func (ledger *Ledger) UpdateStubTxID(stubName string, newTxID string)

UpdateStubTxID updates stub txID

func (*Ledger) WaitChTransferTo

func (ledger *Ledger) WaitChTransferTo(name string, id string, timeout time.Duration)

WaitChTransferTo waits for transfer to event

func (*Ledger) WaitMultiSwapAnswer

func (ledger *Ledger) WaitMultiSwapAnswer(name string, id string, timeout time.Duration)

WaitMultiSwapAnswer waits for multi swap answer

func (*Ledger) WaitSwapAnswer

func (ledger *Ledger) WaitSwapAnswer(name string, id string, timeout time.Duration)

WaitSwapAnswer waits for swap answer

type Metadata

type Metadata struct {
	Name            string          `json:"name"`
	Symbol          string          `json:"symbol"`
	Decimals        uint            `json:"decimals"`
	UnderlyingAsset string          `json:"underlyingAsset"`
	Issuer          string          `json:"issuer"`
	Methods         []string        `json:"methods"`
	TotalEmission   *big.Int        `json:"total_emission"` //nolint:tagliatelle
	Fee             *Fee            `json:"fee"`
	Rates           []*MetadataRate `json:"rates"`
}

Metadata struct

func (Metadata) MethodExists

func (m Metadata) MethodExists(method string) bool

MethodExists checks if method exists

type MetadataGroup

type MetadataGroup struct {
	Name         string    `json:"name"`
	Amount       *big.Int  `json:"amount"`
	MaturityDate time.Time `json:"maturityDate"`
	Note         string    `json:"note"`
}

MetadataGroup struct

type MetadataRate

type MetadataRate struct {
	DealType string   `json:"deal_type"` //nolint:tagliatelle
	Currency string   `json:"currency"`
	Rate     *big.Int `json:"rate"`
	Min      *big.Int `json:"min"`
	Max      *big.Int `json:"max"`
}

MetadataRate struct

type Multisig

type Multisig struct {
	Wallet
	// contains filtered or unexported fields
}

Multisig is a mock for multisig wallet

func (*Multisig) Address

func (w *Multisig) Address() string

Address returns address of multisig wallet

func (*Multisig) AddressType

func (w *Multisig) AddressType() *types.Address

AddressType returns address of multisig wallet

func (*Multisig) ChangeKeysFor

func (w *Multisig) ChangeKeysFor(index int, sKey ed25519.PrivateKey) error

ChangeKeysFor changes private and public keys for Multisig member with specific index

func (*Multisig) PubKeys

func (w *Multisig) PubKeys() []ed25519.PublicKey

PubKeys returns public keys of multisig wallet

func (*Multisig) RawSignedInvoke

func (w *Multisig) RawSignedInvoke(signCnt int, ch string, fn string, args ...string) (string, TxResponse, []*proto.Swap)

RawSignedInvoke invokes chaincode function with specific arguments and signs it with multisig wallet

func (*Multisig) SecretKeys

func (w *Multisig) SecretKeys() []ed25519.PrivateKey

SecretKeys returns private keys of multisig wallet

type Right struct {
	Channel   string
	Chaincode string
	Role      string
	Operation string
	Address   string
}

Right represents a right in the access matrix

func (Right) IsValid

func (r Right) IsValid() error

IsValid checks if the right is valid

type TxResponse

type TxResponse struct {
	Method     string                    `json:"method"`
	Error      string                    `json:"error,omitempty"`
	Result     string                    `json:"result"`
	Events     map[string][]byte         `json:"events,omitempty"`
	Accounting []*proto.AccountingRecord `json:"accounting"`
}

TxResponse returns txResponse event

type Wallet

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

Wallet is a wallet

func (*Wallet) AddAccountRight

func (w *Wallet) AddAccountRight(right *Right) error

AddAccountRight adds a right to the access matrix

func (*Wallet) AddAllowedBalance

func (w *Wallet) AddAllowedBalance(ch string, token string, amount uint64)

AddAllowedBalance adds allowed balance to the wallet

func (*Wallet) AddBalance

func (w *Wallet) AddBalance(ch string, amount uint64)

AddBalance adds balance to the wallet

func (*Wallet) AddGivenBalance

func (w *Wallet) AddGivenBalance(ch string, givenBalanceChannel string, amount uint64)

AddGivenBalance adds given balance to the wallet

func (*Wallet) AddTokenBalance

func (w *Wallet) AddTokenBalance(ch string, token string, amount uint64)

AddTokenBalance adds token balance to the wallet

func (*Wallet) Address

func (w *Wallet) Address() string

Address returns the address of the wallet

func (*Wallet) AddressGOST

func (w *Wallet) AddressGOST() string

func (*Wallet) AddressType

func (w *Wallet) AddressType() *types.Address

AddressType returns the address type of the wallet

func (*Wallet) AllowedBalanceShouldBe

func (w *Wallet) AllowedBalanceShouldBe(ch string, token string, expected uint64)

AllowedBalanceShouldBe checks the allowed balance of the wallet

func (*Wallet) BalanceShouldBe

func (w *Wallet) BalanceShouldBe(ch string, expected uint64)

BalanceShouldBe checks the balance of the wallet

func (*Wallet) BatchedInvoke

func (w *Wallet) BatchedInvoke(ch, fn string, args ...string) (string, TxResponse)

BatchedInvoke invokes a function on the ledger

func (*Wallet) ChangeKeys

func (w *Wallet) ChangeKeys(sKey ed25519.PrivateKey) error

ChangeKeys change private key, then public key will be derived and changed too

func (*Wallet) CheckGivenBalanceShouldBe

func (w *Wallet) CheckGivenBalanceShouldBe(ch string, token string, expectedBalance uint64)

CheckGivenBalanceShouldBe checks the balance of the wallet

func (*Wallet) DoBatch

func (w *Wallet) DoBatch(ch string, txID ...string) BatchTxResponse

DoBatch does a batch transaction

func (*Wallet) GroupBalanceShouldBe

func (w *Wallet) GroupBalanceShouldBe(ch, group string, expected uint64)

GroupBalanceShouldBe checks the group balance of the wallet

func (*Wallet) IndustrialBalanceShouldBe

func (w *Wallet) IndustrialBalanceShouldBe(ch, group string, expected uint64)

IndustrialBalanceShouldBe checks the industrial balance of the wallet

func (*Wallet) Invoke

func (w *Wallet) Invoke(ch, fn string, args ...string) string

Invoke invokes a function on the ledger

func (*Wallet) InvokeReturnsTxID

func (w *Wallet) InvokeReturnsTxID(ch, fn string, args ...string) string

InvokeReturnsTxID invokes a function on the ledger and returns the transaction ID

func (*Wallet) InvokeTraced

func (w *Wallet) InvokeTraced(ctx context.Context, ch, fn string, args ...string) string

func (*Wallet) InvokeWithError

func (w *Wallet) InvokeWithError(ch, fn string, args ...string) error

InvokeWithError invokes a function on the ledger and returns an error

func (*Wallet) InvokeWithPeerResponse

func (w *Wallet) InvokeWithPeerResponse(ch, fn string, args ...string) (peer.Response, error)

func (*Wallet) Ledger

func (w *Wallet) Ledger() *Ledger

Ledger returns the ledger

func (*Wallet) NbInvoke

func (w *Wallet) NbInvoke(ch string, fn string, args ...string) (string, string)

NbInvoke executes non-batched transactions

func (*Wallet) NbInvokeTraced

func (w *Wallet) NbInvokeTraced(ctx context.Context, ch string, fn string, args ...string) (string, string)

NbInvokeTraced executes non-batched transactions with telemetry tracing

func (*Wallet) OtfBalanceShouldBe

func (w *Wallet) OtfBalanceShouldBe(ch string, token string, expected uint64)

OtfBalanceShouldBe checks the otf balance of the wallet

func (*Wallet) OtfNbInvoke deprecated

func (w *Wallet) OtfNbInvoke(ch string, fn string, args ...string) (string, string)

OtfNbInvoke executes non-batched transactions

Deprecated: use NbInvoke instead

func (*Wallet) PubKey

func (w *Wallet) PubKey() []byte

PubKey returns the public key of the wallet

func (*Wallet) RawChTransferInvoke

func (w *Wallet) RawChTransferInvoke(ch, fn string, args ...string) (string, TxResponse, error)

RawChTransferInvoke invokes a function on the ledger

func (*Wallet) RawChTransferInvokeWithBatch

func (w *Wallet) RawChTransferInvokeWithBatch(ch string, fn string, args ...string) (string, TxResponse, error)

RawChTransferInvokeWithBatch invokes a function on the ledger

func (*Wallet) RawSignedInvoke

func (w *Wallet) RawSignedInvoke(ch string, fn string, args ...string) (string, TxResponse, []*proto.Swap)

RawSignedInvoke invokes a function on the ledger

func (*Wallet) RawSignedInvokeTraced

func (w *Wallet) RawSignedInvokeTraced(ctx context.Context, ch, fn string, args ...string) (string, TxResponse, []*proto.Swap)

func (*Wallet) RawSignedInvokeTracedWithErrorReturned

func (w *Wallet) RawSignedInvokeTracedWithErrorReturned(ctx context.Context, ch, fn string, args ...string) error

func (*Wallet) RawSignedInvokeWithErrorReturned

func (w *Wallet) RawSignedInvokeWithErrorReturned(ch, fn string, args ...string) error

RawSignedInvokeWithErrorReturned invokes a function on the ledger

func (*Wallet) RawSignedMultiSwapInvoke

func (w *Wallet) RawSignedMultiSwapInvoke(ch, fn string, args ...string) (string, TxResponse, []*proto.Swap, []*proto.MultiSwap)

RawSignedMultiSwapInvoke invokes a function on the ledger

func (*Wallet) RawSignedMultiSwapInvokeTraced

func (w *Wallet) RawSignedMultiSwapInvokeTraced(ctx context.Context, ch, fn string, args ...string) (string, TxResponse, []*proto.Swap, []*proto.MultiSwap)

func (*Wallet) RemoveAccountRight

func (w *Wallet) RemoveAccountRight(right *Right) error

RemoveAccountRight removes a right from the access matrix

func (*Wallet) SecretKey

func (w *Wallet) SecretKey() []byte

SecretKey returns the secret key of the wallet

func (*Wallet) SetGOSTPrimary

func (w *Wallet) SetGOSTPrimary(primary bool)

func (*Wallet) SetPubKey

func (w *Wallet) SetPubKey(pk ed25519.PublicKey)

SetPubKey sets the public key of the wallet

func (*Wallet) SignArgs

func (w *Wallet) SignArgs(ch, fn string, args ...string) []string

SignArgs signs the arguments

func (*Wallet) SignedInvoke

func (w *Wallet) SignedInvoke(ch string, fn string, args ...string) string

SignedInvoke invokes a function on the ledger

func (*Wallet) SignedInvokeTraced

func (w *Wallet) SignedInvokeTraced(ctx context.Context, ch, fn string, args ...string) string

func (*Wallet) SignedMultiSwapsInvoke

func (w *Wallet) SignedMultiSwapsInvoke(ch string, fn string, args ...string) string

SignedMultiSwapsInvoke invokes a function on the ledger

Directories

Path Synopsis
Package stub mocked provides APIs for the chaincode to access its state variables, transaction context and call other chaincodes.
Package stub mocked provides APIs for the chaincode to access its state variables, transaction context and call other chaincodes.

Jump to

Keyboard shortcuts

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