Documentation ¶
Index ¶
- Variables
- type Base64EncodedBlob
- type CanisterIDRange
- type Config
- type CreateHttpGatewayResponse
- type DTSFlag
- type EffectivePrincipal
- type EffectivePrincipalCanisterID
- type EffectivePrincipalNone
- type EffectivePrincipalSubnetID
- type ErrorMessage
- type HttpGatewayBackend
- type HttpGatewayBackendPocketICInstance
- type HttpGatewayBackendReplica
- type HttpGatewayConfig
- type HttpGatewayInfo
- type InstanceConfig
- type MessageID
- type None
- type Option
- func WithApplicationSubnet() Option
- func WithBitcoinSubnet() Option
- func WithDTSFlag() Option
- func WithFiduciarySubnet() Option
- func WithHTTPClient(client *http.Client) Option
- func WithIISubnet() Option
- func WithLogger(logger agent.Logger) Option
- func WithNNSSubnet() Option
- func WithPollingDelay(delay, timeout time.Duration) Option
- func WithSNSSubnet() Option
- func WithSubnetConfigSet(subnetConfig SubnetConfigSet) Option
- func WithSystemSubnet() Option
- func WithTTL(ttl int) Option
- type PocketIC
- func (pic PocketIC) AddCycles(canisterID principal.Principal, amount int) (int, error)
- func (pic PocketIC) AutoProgress() error
- func (pic PocketIC) AwaitCall(messageID MessageID) ([]byte, error)
- func (pic PocketIC) CreateAndInstallCode(wasmModule []byte, arg []byte, optSender *principal.Principal) (*principal.Principal, error)
- func (pic PocketIC) CreateCanister() (*principal.Principal, error)
- func (pic PocketIC) CreateCanisterOnSubnet(subnetID principal.Principal, args ProvisionalCreateCanisterArgument) (*principal.Principal, error)
- func (pic PocketIC) CreateCanisterWithArgs(args ProvisionalCreateCanisterArgument) (*principal.Principal, error)
- func (pic PocketIC) CreateCanisterWithID(canisterID principal.Principal, args ProvisionalCreateCanisterArgument) (*principal.Principal, error)
- func (pic PocketIC) CreateInstance(config SubnetConfigSet) (*InstanceConfig, error)
- func (pic PocketIC) DeleteInstance(instanceID int) error
- func (pic PocketIC) ExecuteCall(canisterID principal.Principal, effectivePrincipal EffectivePrincipal, ...) ([]byte, error)
- func (pic PocketIC) GetBlob(blobID []byte) ([]byte, error)
- func (pic PocketIC) GetCycles(canisterID principal.Principal) (int, error)
- func (pic PocketIC) GetInstances() ([]string, error)
- func (pic PocketIC) GetStableMemory(canisterID principal.Principal) ([]byte, error)
- func (pic PocketIC) GetSubnet(canisterID principal.Principal) (*principal.Principal, error)
- func (pic PocketIC) GetTime() (*time.Time, error)
- func (pic PocketIC) InstallCode(canisterID principal.Principal, wasmModule []byte, arg []byte, ...) error
- func (pic PocketIC) InstanceURL() string
- func (pic PocketIC) MakeDeterministic() error
- func (pic PocketIC) MakeLive(port *int) (string, error)
- func (pic PocketIC) QueryCall(canisterID principal.Principal, sender principal.Principal, method string, ...) error
- func (pic PocketIC) RootKey() ([]byte, error)
- func (pic PocketIC) SetStableMemory(canisterID principal.Principal, data []byte, gzipCompression bool) error
- func (pic PocketIC) SetTime(time time.Time) error
- func (pic PocketIC) Status() error
- func (pic PocketIC) StopProgress() error
- func (pic PocketIC) SubmitCall(canisterID principal.Principal, sender principal.Principal, method string, ...) (*MessageID, error)
- func (pic PocketIC) SubmitCallWithEP(canisterID principal.Principal, effectivePrincipal EffectivePrincipal, ...) (*MessageID, error)
- func (pic PocketIC) Tick() error
- func (pic PocketIC) Topology() map[string]Topology
- func (pic PocketIC) UninstallCode(canisterID principal.Principal, optSender *principal.Principal) error
- func (pic PocketIC) UpdateCall(canisterID principal.Principal, sender principal.Principal, method string, ...) error
- func (pic PocketIC) UploadBlob(bytes []byte, gzipCompression bool) ([]byte, error)
- func (pic PocketIC) VerifySignature(sig VerifyCanisterSigArg) error
- type ProvisionalCreateCanisterArgument
- type RawCanisterID
- type Reject
- type SubnetConfigSet
- type SubnetID
- type SubnetInstructionConfig
- type SubnetInstructionConfigBenchmarking
- type SubnetInstructionConfigProduction
- type SubnetKind
- type SubnetSpec
- type SubnetStateConfig
- type SubnetStateConfigFromPath
- type SubnetStateConfigNew
- type Topology
- type UserError
- type VerifyCanisterSigArg
Constants ¶
This section is empty.
Variables ¶
var ( DefaultSubnetSpec = SubnetSpec{ StateConfig: SubnetStateConfigNew{}, InstructionConfig: SubnetInstructionConfigProduction{}, DTSFlag: false, } DefaultSubnetConfig = SubnetConfigSet{ NNS: &DefaultSubnetSpec, Application: make([]SubnetSpec, 0), System: make([]SubnetSpec, 0), } )
Functions ¶
This section is empty.
Types ¶
type Base64EncodedBlob ¶
type Base64EncodedBlob []byte
Base64EncodedBlob is a byte slice that is base64 encoded when marshaled to JSON. The underlying byte slice is already decoded, so it can be used as is.
func (Base64EncodedBlob) MarshalJSON ¶
func (b Base64EncodedBlob) MarshalJSON() ([]byte, error)
func (Base64EncodedBlob) String ¶
func (b Base64EncodedBlob) String() string
String returns the base64 encoded string of the blob. NOTE: it will truncate the string if it is too long.
func (*Base64EncodedBlob) UnmarshalJSON ¶
func (b *Base64EncodedBlob) UnmarshalJSON(bytes []byte) error
type CanisterIDRange ¶
func (CanisterIDRange) MarshalJSON ¶
func (c CanisterIDRange) MarshalJSON() ([]byte, error)
func (*CanisterIDRange) UnmarshalJSON ¶
func (c *CanisterIDRange) UnmarshalJSON(bytes []byte) error
type CreateHttpGatewayResponse ¶
type CreateHttpGatewayResponse struct { Created *HttpGatewayInfo `json:"Created,omitempty"` Error *ErrorMessage `json:"Error,omitempty"` }
type EffectivePrincipal ¶ added in v0.4.4
type EffectivePrincipal interface {
// contains filtered or unexported methods
}
type EffectivePrincipalCanisterID ¶ added in v0.4.4
type EffectivePrincipalCanisterID struct {
CanisterID Base64EncodedBlob `json:"CanisterId"`
}
type EffectivePrincipalNone ¶ added in v0.4.4
type EffectivePrincipalNone struct{}
func (EffectivePrincipalNone) MarshalJSON ¶ added in v0.4.4
func (n EffectivePrincipalNone) MarshalJSON() ([]byte, error)
func (EffectivePrincipalNone) UnmarshalJSON ¶ added in v0.4.4
func (n EffectivePrincipalNone) UnmarshalJSON(bytes []byte) error
type EffectivePrincipalSubnetID ¶ added in v0.4.4
type EffectivePrincipalSubnetID struct {
SubnetID Base64EncodedBlob `json:"SubnetId"`
}
type ErrorMessage ¶
type ErrorMessage struct {
Message string `json:"message"`
}
func (ErrorMessage) Error ¶
func (e ErrorMessage) Error() string
type HttpGatewayBackend ¶
type HttpGatewayBackend interface {
// contains filtered or unexported methods
}
type HttpGatewayBackendPocketICInstance ¶
type HttpGatewayBackendPocketICInstance struct {
PocketIcInstance int `json:"PocketIcInstance"`
}
type HttpGatewayBackendReplica ¶
type HttpGatewayBackendReplica struct {
Replica string `json:"Replica"`
}
type HttpGatewayConfig ¶
type HttpGatewayConfig struct { ListenAt *int `json:"listen_at,omitempty"` ForwardTo HttpGatewayBackend `json:"forward_to"` }
func (*HttpGatewayConfig) UnmarshalJSON ¶
func (h *HttpGatewayConfig) UnmarshalJSON(bytes []byte) error
type HttpGatewayInfo ¶
type InstanceConfig ¶
type MessageID ¶ added in v0.4.4
type MessageID struct { EffectivePrincipal EffectivePrincipal `json:"effective_principal"` MessageID Base64EncodedBlob `json:"message_id"` }
func (*MessageID) UnmarshalJSON ¶ added in v0.4.4
type Option ¶
type Option func(*Config)
func WithApplicationSubnet ¶
func WithApplicationSubnet() Option
WithApplicationSubnet adds an empty Application subnet.
func WithBitcoinSubnet ¶
func WithBitcoinSubnet() Option
WithBitcoinSubnet adds an empty Bitcoin subnet.
func WithFiduciarySubnet ¶
func WithFiduciarySubnet() Option
WithFiduciarySubnet adds an empty Fiduciary subnet.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client for the PocketIC client.
func WithLogger ¶
func WithLogger(logger agent.Logger) Option
WithLogger sets the logger for the PocketIC client.
func WithPollingDelay ¶
func WithSubnetConfigSet ¶
func WithSubnetConfigSet(subnetConfig SubnetConfigSet) Option
WithSubnetConfigSet sets the subnet configuration.
func WithSystemSubnet ¶
func WithSystemSubnet() Option
WithSystemSubnet adds an empty System subnet.
type PocketIC ¶
type PocketIC struct { InstanceID int // contains filtered or unexported fields }
PocketIC is a client for the local PocketIC server.
func New ¶
New creates a new PocketIC client. The order of the options is important, some options may override others.
func (PocketIC) AutoProgress ¶
AutoProgress configures the IC to make progress automatically, i.e., periodically update the time of the IC to the real time and execute rounds on the subnets. Returns the URL at which `/api/v2` requests for this instance can be made.
func (PocketIC) AwaitCall ¶
AwaitCall awaits an update call submitted previously by `submit_call_with_effective_principal`.
func (PocketIC) CreateAndInstallCode ¶ added in v0.4.4
func (PocketIC) CreateCanister ¶
CreateCanister creates a canister with default settings as the anonymous principal.
func (PocketIC) CreateCanisterOnSubnet ¶
func (pic PocketIC) CreateCanisterOnSubnet(subnetID principal.Principal, args ProvisionalCreateCanisterArgument) (*principal.Principal, error)
CreateCanisterOnSubnet creates a canister on the specified subnet with the specified settings.
func (PocketIC) CreateCanisterWithArgs ¶
func (pic PocketIC) CreateCanisterWithArgs(args ProvisionalCreateCanisterArgument) (*principal.Principal, error)
CreateCanisterWithArgs creates a canister with the specified settings and cycles.
func (PocketIC) CreateCanisterWithID ¶
func (pic PocketIC) CreateCanisterWithID(canisterID principal.Principal, args ProvisionalCreateCanisterArgument) (*principal.Principal, error)
CreateCanisterWithID creates a canister with the specified canister ID and settings.
func (PocketIC) CreateInstance ¶
func (pic PocketIC) CreateInstance(config SubnetConfigSet) (*InstanceConfig, error)
CreateInstance creates a new PocketIC instance.
func (PocketIC) DeleteInstance ¶
DeleteInstance deletes a PocketIC instance.
func (PocketIC) ExecuteCall ¶
func (pic PocketIC) ExecuteCall( canisterID principal.Principal, effectivePrincipal EffectivePrincipal, sender principal.Principal, method string, payload []byte, ) ([]byte, error)
ExecuteCall executes an update call on a canister.
func (PocketIC) GetInstances ¶
GetInstances lists all PocketIC instance availabilities.
func (PocketIC) GetStableMemory ¶
GetStableMemory returns the stable memory of a canister.
func (PocketIC) InstallCode ¶
func (pic PocketIC) InstallCode(canisterID principal.Principal, wasmModule []byte, arg []byte, optSender *principal.Principal) error
InstallCode installs a canister with the specified wasm module and arguments.
func (PocketIC) InstanceURL ¶
InstanceURL returns the URL of the PocketIC instance.
func (PocketIC) MakeDeterministic ¶
MakeDeterministic makes the IC instance deterministic by stopping automatic progress (time updates and round executions) on the IC instance and stops the HTTP gateway for this IC instance.
func (PocketIC) MakeLive ¶
MakeLive creates an HTTP gateway for this IC instance listening on an optionally specified port and configures the IC instance to make progress automatically, i.e., periodically update the time of the IC to the real time and execute rounds on the subnets. Returns the URL at which `/api/v2` requests for this instance can be made.
func (PocketIC) QueryCall ¶
func (pic PocketIC) QueryCall(canisterID principal.Principal, sender principal.Principal, method string, args []any, ret []any) error
QueryCall executes a query call on a canister.
func (PocketIC) SetStableMemory ¶
func (pic PocketIC) SetStableMemory(canisterID principal.Principal, data []byte, gzipCompression bool) error
SetStableMemory sets the stable memory of a canister.
func (PocketIC) StopProgress ¶
StopProgress stops automatic progress (see `auto_progress`) on the IC.
func (PocketIC) SubmitCall ¶
func (pic PocketIC) SubmitCall( canisterID principal.Principal, sender principal.Principal, method string, payload []byte, ) (*MessageID, error)
SubmitCall submits an update call (without executing it immediately).
func (PocketIC) SubmitCallWithEP ¶
func (pic PocketIC) SubmitCallWithEP( canisterID principal.Principal, effectivePrincipal EffectivePrincipal, sender principal.Principal, method string, payload []byte, ) (*MessageID, error)
SubmitCallWithEP submits an update call with a provided effective principal (without executing it immediately).
func (PocketIC) UninstallCode ¶
func (pic PocketIC) UninstallCode(canisterID principal.Principal, optSender *principal.Principal) error
UninstallCode uninstalls a canister.
func (PocketIC) UpdateCall ¶
func (pic PocketIC) UpdateCall(canisterID principal.Principal, sender principal.Principal, method string, args []any, ret []any) error
UpdateCall executes an update call on a canister.
func (PocketIC) UploadBlob ¶
UploadBlob uploads and stores a binary blob to the PocketIC server.
func (PocketIC) VerifySignature ¶
func (pic PocketIC) VerifySignature(sig VerifyCanisterSigArg) error
VerifySignature verifies a signature.
type ProvisionalCreateCanisterArgument ¶
type ProvisionalCreateCanisterArgument struct { Settings *ic0.CanisterSettings `ic:"settings"` SpecifiedID *principal.Principal `ic:"specified_id"` Amount *int `ic:"amount"` }
type RawCanisterID ¶
type RawCanisterID struct {
CanisterID Base64EncodedBlob `json:"canister_id"`
}
type SubnetConfigSet ¶
type SubnetConfigSet struct { Application []SubnetSpec `json:"application"` Bitcoin *SubnetSpec `json:"bitcoin,omitempty"` Fiduciary *SubnetSpec `json:"fiduciary,omitempty"` II *SubnetSpec `json:"ii,omitempty"` NNS *SubnetSpec `json:"nns,omitempty"` SNS *SubnetSpec `json:"sns,omitempty"` System []SubnetSpec `json:"system"` }
type SubnetID ¶ added in v0.4.4
type SubnetID struct {
SubnetID Base64EncodedBlob `json:"subnet_id"`
}
type SubnetInstructionConfig ¶
type SubnetInstructionConfig interface {
// contains filtered or unexported methods
}
type SubnetInstructionConfigBenchmarking ¶
type SubnetInstructionConfigBenchmarking struct{}
SubnetInstructionConfigBenchmarking uses very high instruction limits useful for asymptotic canister benchmarking.
func (SubnetInstructionConfigBenchmarking) MarshalJSON ¶
func (c SubnetInstructionConfigBenchmarking) MarshalJSON() ([]byte, error)
func (SubnetInstructionConfigBenchmarking) UnmarshalJSON ¶
func (c SubnetInstructionConfigBenchmarking) UnmarshalJSON(bytes []byte) error
type SubnetInstructionConfigProduction ¶
type SubnetInstructionConfigProduction struct{}
SubnetInstructionConfigProduction uses default instruction limits as in production.
func (SubnetInstructionConfigProduction) MarshalJSON ¶
func (c SubnetInstructionConfigProduction) MarshalJSON() ([]byte, error)
func (SubnetInstructionConfigProduction) UnmarshalJSON ¶
func (c SubnetInstructionConfigProduction) UnmarshalJSON(bytes []byte) error
type SubnetKind ¶
type SubnetKind string
var ( ApplicationSubnet SubnetKind = "Application" BitcoinSubnet SubnetKind = "Bitcoin" FiduciarySubnet SubnetKind = "Fiduciary" IISubnet SubnetKind = "II" NNSSubnet SubnetKind = "NNS" SNSSubnet SubnetKind = "SNS" SystemSubnet SubnetKind = "System" )
type SubnetSpec ¶
type SubnetSpec struct { StateConfig SubnetStateConfig `json:"state_config"` InstructionConfig SubnetInstructionConfig `json:"instruction_config"` DTSFlag DTSFlag `json:"dts_flag"` }
SubnetSpec specifies various configurations for a subnet.
func (*SubnetSpec) WithDTSFlag ¶
func (s *SubnetSpec) WithDTSFlag()
WithDTSFlag sets the DTS flag, returns if the SubnetSpec is nil. Safe to call on a nil SubnetSpec.
type SubnetStateConfig ¶
type SubnetStateConfig interface {
// contains filtered or unexported methods
}
type SubnetStateConfigFromPath ¶
SubnetStateConfigFromPath load existing subnet state from the given path. The path must be on a filesystem accessible to the server process.
func (SubnetStateConfigFromPath) MarshalJSON ¶
func (c SubnetStateConfigFromPath) MarshalJSON() ([]byte, error)
func (SubnetStateConfigFromPath) UnmarshalJSON ¶
func (c SubnetStateConfigFromPath) UnmarshalJSON(bytes []byte) error
type SubnetStateConfigNew ¶
type SubnetStateConfigNew struct{}
SubnetStateConfigNew creates new subnet with empty state.
func (SubnetStateConfigNew) MarshalJSON ¶
func (c SubnetStateConfigNew) MarshalJSON() ([]byte, error)
func (SubnetStateConfigNew) UnmarshalJSON ¶
func (c SubnetStateConfigNew) UnmarshalJSON(bytes []byte) error
type Topology ¶
type Topology struct { SubnetKind SubnetKind `json:"subnet_kind"` Size int `json:"size"` CanisterRanges []CanisterIDRange `json:"canister_ranges"` }
type VerifyCanisterSigArg ¶ added in v0.4.4
type VerifyCanisterSigArg struct { Message Base64EncodedBlob `json:"msg"` PublicKey Base64EncodedBlob `json:"pubkey"` RootPubKey Base64EncodedBlob `json:"root_pubkey"` Signature Base64EncodedBlob `json:"sig"` }