mock

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrRightNotSet = "right is not set"

	ErrChannelNotSet   = "right is broken, channel is not set"
	ErrChaincodeNotSet = "right is broken, chaincode is not set"
	ErrRoleNotSet      = "right is broken, role is not set"
	ErrAddressNotSet   = "right is broken, address is not set"

	ErrNomineeAddressNotSet   = "right is broken, nominee address is not set"
	ErrPrincipalAddressNotSet = "right is broken, principal address is not set"
)

Errors

View Source
const (
	// FnAddRights adds a right to the access matrix
	FnAddRights operation = "addRights"
	// FnRemoveRights removes a right from the access matrix
	FnRemoveRights operation = "removeRights"
	// FnAddAddressRightForNominee adds right to access matrix
	FnAddAddressRightForNominee operation = "addAddressRightForNominee"
	// FnRemoveAddressRightFromNominee adds right to access matrix
	FnRemoveAddressRightFromNominee operation = "removeAddressRightFromNominee"
)

Function names

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressRight added in v0.0.8

type AddressRight struct {
	Channel          string
	Chaincode        string
	NomineeAddress   string
	PrincipalAddress string
}

AddressRight defines address right for nominee in access matrix

func (AddressRight) IsValid added in v0.0.8

func (ar AddressRight) IsValid() error

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 ExecutorRequest added in v0.0.2

type ExecutorRequest struct {
	Channel        string
	Method         string
	Args           []string
	IsSignedInvoke bool
}

func NewExecutorRequest added in v0.0.2

func NewExecutorRequest(ch string, fn string, args []string, isSignedInvoke bool) ExecutorRequest

type ExecutorResponse added in v0.0.2

type ExecutorResponse struct {
	TxResponse   *proto.TxResponse
	BatchTxEvent *proto.BatchTxEvent
}

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 deprecated

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

Deprecated: use package ../mocks instead

func NewLedger deprecated

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

Deprecated: use package ../mocks instead NewLedger creates new ledger

func (*Ledger) GetPending deprecated

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

Deprecated: use package ../mocks instead GetPending returns pending transactions

func (*Ledger) GetStub deprecated

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

Deprecated: use package ../mocks instead GetStub returns stub

func (*Ledger) GetStubByKey deprecated

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

Deprecated: use package ../mocks instead GetStubByKey returns stub by key

func (*Ledger) IndustrialMetadata deprecated

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

Deprecated: use package ../mocks instead IndustrialMetadata returns metadata for industrial token

func (*Ledger) Metadata deprecated

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

Deprecated: use package ../mocks instead Metadata returns metadata

func (*Ledger) NewCC deprecated

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

Deprecated: use package ../mocks instead

func (*Ledger) NewCCArgsArr

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

NewCCArgsArr Deprecated: added only for backward compatibility.

func (*Ledger) NewMultisigWallet deprecated

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

Deprecated: use package ../mocks instead NewMultisigWallet creates new multisig wallet

func (*Ledger) NewWallet deprecated

func (l *Ledger) NewWallet() *Wallet

Deprecated: use package ../mocks instead NewWallet creates new wallet

func (*Ledger) NewWalletFromHexKey deprecated

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

Deprecated: use package ../mocks instead NewWalletFromHexKey creates new wallet from hex key

func (*Ledger) NewWalletFromKey deprecated

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

Deprecated: use package ../mocks instead NewWalletFromKey creates new wallet from key

func (*Ledger) SetACL deprecated

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

Deprecated: use package ../mocks instead SetACL sets acl stub

func (*Ledger) UpdateStubTxID deprecated

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

Deprecated: use package ../mocks instead UpdateStubTxID updates stub txID

func (*Ledger) WaitChTransferTo deprecated

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

Deprecated: use package ../mocks instead WaitChTransferTo waits for transfer to event

func (*Ledger) WaitMultiSwapAnswer

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

WaitMultiSwapAnswer waits for multi swap answer

func (*Ledger) WaitSwapAnswer deprecated

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

Deprecated: use package ../mocks instead 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 deprecated

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

Deprecated: use package ../mocks instead Multisig is a mock for multisig wallet

func (*Multisig) Address deprecated

func (w *Multisig) Address() string

Deprecated: use package ../mocks instead Address returns address of multisig wallet

func (*Multisig) AddressType deprecated

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

Deprecated: use package ../mocks instead AddressType returns address of multisig wallet

func (*Multisig) ChangeKeysFor deprecated

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

Deprecated: use package ../mocks instead ChangeKeysFor changes private and public keys for Multisig member with specific index

func (*Multisig) PubKeys deprecated

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

Deprecated: use package ../mocks instead PubKeys returns public keys of multisig wallet

func (*Multisig) RawSignedInvoke deprecated

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

Deprecated: use package ../mocks instead RawSignedInvoke invokes chaincode function with specific arguments and signs it with multisig wallet

func (*Multisig) SecretKeys deprecated

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

Deprecated: use package ../mocks instead SecretKeys returns private keys of multisig wallet

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

Right defines 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 deprecated

type Wallet struct {
	*keys.Keys
	// contains filtered or unexported fields
}

Deprecated: use package ../mocks instead Wallet is a wallet

func (*Wallet) AddAccountRight deprecated

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

Deprecated: use package ../mocks instead AddAccountRight adds a right to the access matrix

func (*Wallet) AddAddressRightForNominee deprecated added in v0.0.8

func (w *Wallet) AddAddressRightForNominee(right *AddressRight) error

Deprecated: use package ../mocks instead AddAddressRightForNominee adds right to transfer from specified principal address for nominee

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 deprecated

func (w *Wallet) Address() string

Deprecated: use package ../mocks instead Address returns the address of the wallet

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 deprecated

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

Deprecated: use package ../mocks instead 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) ExecuteNoSignedInvoke deprecated added in v0.0.5

func (w *Wallet) ExecuteNoSignedInvoke(ch string, fn string, args ...string) ([]byte, error)

Deprecated: use package ../mocks instead

func (*Wallet) ExecuteSignedInvoke deprecated added in v0.0.2

func (w *Wallet) ExecuteSignedInvoke(ch string, fn string, args ...string) ([]byte, error)

Deprecated: use package ../mocks instead

func (*Wallet) GivenBalanceShouldBe added in v0.0.6

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

GivenBalanceShouldBe checks the given balance of the channel

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 deprecated

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

Deprecated: use package ../mocks instead

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 deprecated

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

Deprecated: use package ../mocks instead 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 deprecated

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

Deprecated: use package ../mocks instead 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 deprecated

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

Deprecated: use package ../mocks instead

func (*Wallet) RawSignedInvokeTracedWithErrorReturned deprecated

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

Deprecated: use package ../mocks instead

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 deprecated

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

Deprecated: use package ../mocks instead

func (*Wallet) RemoveAccountRight deprecated

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

Deprecated: use package ../mocks instead RemoveAccountRight removes a right from the access matrix

func (*Wallet) RemoveAddressRightFromNominee deprecated added in v0.0.8

func (w *Wallet) RemoveAddressRightFromNominee(right *AddressRight) error

Deprecated: use package ../mocks instead RemoveAddressRightFromNominee removes right to transfer from specified principal address from nominee

func (*Wallet) SecretKey

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

SecretKey returns the secret key of the wallet

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 deprecated

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

Deprecated: use package ../mocks instead

func (*Wallet) SignedMultiSwapsInvoke

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

SignedMultiSwapsInvoke invokes a function on the ledger

func (*Wallet) TaskExecutorRequest deprecated added in v0.0.5

func (w *Wallet) TaskExecutorRequest(channel string, requests ...ExecutorRequest) ([]ExecutorResponse, error)

Deprecated: use package ../mocks instead

func (*Wallet) TasksExecutor deprecated added in v0.0.5

func (w *Wallet) TasksExecutor(channel string, tasks []*proto.Task) (*proto.BatchResponse, error)

Deprecated: use package ../mocks instead

func (*Wallet) UseGOSTKey deprecated added in v0.0.2

func (w *Wallet) UseGOSTKey()

Deprecated: use package ../mocks instead

func (*Wallet) UseSecp256k1Key deprecated added in v0.0.2

func (w *Wallet) UseSecp256k1Key()

Deprecated: use package ../mocks instead

func (*Wallet) WithNonceSignArgs added in v0.0.5

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

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