Documentation ¶
Index ¶
- Constants
- Variables
- func BalanceClosingHash(clientAddr, pscAddr common.Address, block uint32, offeringHash common.Hash, ...) []byte
- func BalanceProofHash(pscAddr, agentAddr common.Address, block uint32, offeringHash common.Hash, ...) []byte
- type Backend
- type Config
- type TestEthBackCall
- type TestEthBackend
- func (b *TestEthBackend) CooperativeClose(opts *bind.TransactOpts, agentAddr common.Address, block uint32, ...) (*types.Transaction, error)
- func (b *TestEthBackend) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
- func (b *TestEthBackend) EthBalanceAt(_ context.Context, addr common.Address) (*big.Int, error)
- func (b *TestEthBackend) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
- func (b *TestEthBackend) GetTransactionByHash(context.Context, common.Hash) (*types.Transaction, bool, error)
- func (b *TestEthBackend) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (b *TestEthBackend) LatestBlockNumber(ctx context.Context) (*big.Int, error)
- func (b *TestEthBackend) PSCAddBalanceERC20(opts *bind.TransactOpts, val uint64) (*types.Transaction, error)
- func (b *TestEthBackend) PSCAddress() common.Address
- func (b *TestEthBackend) PSCBalanceOf(opts *bind.CallOpts, addr common.Address) (uint64, error)
- func (b *TestEthBackend) PSCCreateChannel(opts *bind.TransactOpts, agent common.Address, hash [common.HashLength]byte, ...) (*types.Transaction, error)
- func (b *TestEthBackend) PSCGetChannelInfo(opts *bind.CallOpts, client common.Address, agent common.Address, ...) (uint64, uint32, uint64, error)
- func (b *TestEthBackend) PSCGetOfferingInfo(opts *bind.CallOpts, hash [common.HashLength]byte) (agentAddr common.Address, minDeposit uint64, maxSupply uint16, ...)
- func (b *TestEthBackend) PSCPopupServiceOffering(opts *bind.TransactOpts, offeringHash [32]byte, somcType uint8, ...) (*types.Transaction, error)
- func (b *TestEthBackend) PSCRemoveServiceOffering(opts *bind.TransactOpts, offeringHash [32]byte) (*types.Transaction, error)
- func (b *TestEthBackend) PSCReturnBalanceERC20(opts *bind.TransactOpts, val uint64) (*types.Transaction, error)
- func (b *TestEthBackend) PSCSettle(opts *bind.TransactOpts, agent common.Address, blockNumber uint32, ...) (*types.Transaction, error)
- func (b *TestEthBackend) PSCTopUpChannel(opts *bind.TransactOpts, agent common.Address, blockNumber uint32, ...) (*types.Transaction, error)
- func (b *TestEthBackend) PSCUncooperativeClose(opts *bind.TransactOpts, agent common.Address, blockNumber uint32, ...) (*types.Transaction, error)
- func (b *TestEthBackend) PTCAddress() common.Address
- func (b *TestEthBackend) PTCBalanceOf(opts *bind.CallOpts, addr common.Address) (*big.Int, error)
- func (b *TestEthBackend) PTCIncreaseApproval(opts *bind.TransactOpts, addr common.Address, amount *big.Int) (*types.Transaction, error)
- func (b *TestEthBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (b *TestEthBackend) RegisterServiceOffering(opts *bind.TransactOpts, offeringHash [32]byte, minDeposit uint64, ...) (*types.Transaction, error)
- func (b *TestEthBackend) SetTransaction(t *testing.T, opts *bind.TransactOpts, input []byte)
- func (b *TestEthBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (b *TestEthBackend) TestCalled(t *testing.T, method string, caller common.Address, gasLimit uint64, ...)
Constants ¶
const ( // CRC16("github.com/privatix/dappctrl/eth") = 0x82E7 ErrURLScheme errors.Error = 0x82E7<<8 + iota ErrCreateClient )
Errors.
const ( TestTXNonce uint64 = 1 TestTXGasLimit uint64 = 2 TestTXGasPrice int64 = 1 )
Test constants.
const BlockDuration = time.Duration(15) * time.Second
BlockDuration is an average block duration.
Variables ¶
var ( // PSC logs. ServiceChannelCreated = common.HexToHash("7699dfbb1101aec58b1cfb4a4f5375947c99cb4c645112290d1cb77fc286edc1") ServiceChannelToppedUp = common.HexToHash("d3020c549112ceb2d0f806cd3366f47df57bc519c46133b84ce2cdad970c22a3") ServiceChannelCloseRequested = common.HexToHash("e4007f6ff086417a4031cdcff1a975882379b19e1ed3547292e131f3c525bcab") ServiceOfferingCreated = common.HexToHash("a8c40ba917b58ddcfe866c5b52d417e5e425c459c3b7333bf3b1164e32ddb939") ServiceOfferingDeleted = common.HexToHash("c3013cd9dd5c33b95a9cc1bc076481c9a6a1970be6d7f1ed33adafad6e57d3d6") ServiceOfferingPopedUp = common.HexToHash("7c6ee8c3412a9ecfd989aa18d379f84f73b718366934885e21e9a399b719c53a") ServiceCooperativeChannelClose = common.HexToHash("4a06175bd19aba21163e3c08e7ac80151fad270655624167c5ee9e41b48a58e0") ServiceUnCooperativeChannelClose = common.HexToHash("d633584c5931ade1a274b7ce309d985207494d074d1afd2f2da5275bb645e3dc") // PTC logs. TokenApproval = common.HexToHash("8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925") TokenTransfer = common.HexToHash("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef") )
Logs hexes.
Functions ¶
Types ¶
type Backend ¶
type Backend interface { PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) LatestBlockNumber(ctx context.Context) (*big.Int, error) SuggestGasPrice(ctx context.Context) (*big.Int, error) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error) CooperativeClose(*bind.TransactOpts, common.Address, uint32, [common.HashLength]byte, uint64, []byte, []byte) (*types.Transaction, error) GetTransactionByHash(context.Context, common.Hash) (*types.Transaction, bool, error) RegisterServiceOffering(*bind.TransactOpts, [common.HashLength]byte, uint64, uint16, uint8, data.Base64String) (*types.Transaction, error) PTCBalanceOf(*bind.CallOpts, common.Address) (*big.Int, error) PTCIncreaseApproval(*bind.TransactOpts, common.Address, *big.Int) (*types.Transaction, error) PSCBalanceOf(*bind.CallOpts, common.Address) (uint64, error) PSCAddBalanceERC20(*bind.TransactOpts, uint64) (*types.Transaction, error) PSCGetChannelInfo(opts *bind.CallOpts, client common.Address, agent common.Address, blockNumber uint32, hash [common.HashLength]byte) (uint64, uint32, uint64, error) PSCReturnBalanceERC20(*bind.TransactOpts, uint64) (*types.Transaction, error) PSCGetOfferingInfo(opts *bind.CallOpts, hash [common.HashLength]byte) (agentAddr common.Address, minDeposit uint64, maxSupply uint16, currentSupply uint16, updateBlockNumber uint32, active bool, err error) PSCCreateChannel(opts *bind.TransactOpts, agent common.Address, hash [common.HashLength]byte, deposit uint64) (*types.Transaction, error) PSCTopUpChannel(opts *bind.TransactOpts, agent common.Address, blockNumber uint32, hash [common.HashLength]byte, deposit uint64) (*types.Transaction, error) PSCUncooperativeClose(opts *bind.TransactOpts, agent common.Address, blockNumber uint32, hash [common.HashLength]byte, balance uint64) (*types.Transaction, error) EthBalanceAt(context.Context, common.Address) (*big.Int, error) PSCSettle(opts *bind.TransactOpts, agent common.Address, blockNumber uint32, hash [common.HashLength]byte) (*types.Transaction, error) PSCRemoveServiceOffering(opts *bind.TransactOpts, offeringHash [32]byte) (*types.Transaction, error) PSCPopupServiceOffering(opts *bind.TransactOpts, offeringHash [32]byte, somcType uint8, somcData data.Base64String) (*types.Transaction, error) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) PTCAddress() common.Address PSCAddress() common.Address }
Backend adapter to communicate with contract.
type Config ¶
type Config struct { CheckTimeout uint64 // In milliseconds. Contract struct { PTCAddrHex string PSCAddrHex string } GethURL string Timeout uint64 // In milliseconds. HTTPClient *httpClientConf }
Config is a configuration for Ethereum client.
type TestEthBackCall ¶
type TestEthBackCall struct {
// contains filtered or unexported fields
}
TestEthBackCall is mock for Ethereum backend.
type TestEthBackend ¶
type TestEthBackend struct { CallStack []TestEthBackCall BalanceEth *big.Int BalancePSC uint64 BalancePTC *big.Int BlockNumber *big.Int Abi abi.ABI PscAddr common.Address Tx *types.Transaction OfferingAgent common.Address OfferMinDeposit uint64 OfferCurrentSupply uint16 OfferMaxSupply uint16 OfferUpdateBlockNumber uint32 OfferingIsActive bool GasPrice *big.Int EstimatedGas uint64 }
TestEthBackend is mock for Backend.
func NewTestEthBackend ¶
func NewTestEthBackend(pscAddr common.Address) *TestEthBackend
NewTestEthBackend creates new TestEthBackend instance.
func (*TestEthBackend) CooperativeClose ¶
func (b *TestEthBackend) CooperativeClose(opts *bind.TransactOpts, agentAddr common.Address, block uint32, offeringHash [32]byte, balance uint64, balanceMsgSig []byte, ClosingSig []byte) (*types.Transaction, error)
CooperativeClose is mock to CooperativeClose.
func (*TestEthBackend) EstimateGas ¶
func (b *TestEthBackend) EstimateGas( ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
EstimateGas is mock to EstimateGas.
func (*TestEthBackend) EthBalanceAt ¶
EthBalanceAt is mock to EthBalanceAt.
func (*TestEthBackend) FilterLogs ¶
func (b *TestEthBackend) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
FilterLogs is mock to FilterLogs.
func (*TestEthBackend) GetTransactionByHash ¶
func (b *TestEthBackend) GetTransactionByHash(context.Context, common.Hash) (*types.Transaction, bool, error)
GetTransactionByHash is mock to GetTransactionByHash.
func (*TestEthBackend) HeaderByNumber ¶
func (b *TestEthBackend) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
HeaderByNumber is mock to HeaderByNumber.
func (*TestEthBackend) LatestBlockNumber ¶
LatestBlockNumber is mock to LatestBlockNumber.
func (*TestEthBackend) PSCAddBalanceERC20 ¶
func (b *TestEthBackend) PSCAddBalanceERC20(opts *bind.TransactOpts, val uint64) (*types.Transaction, error)
PSCAddBalanceERC20 is mock to PSCAddBalanceERC20.
func (*TestEthBackend) PSCAddress ¶
func (b *TestEthBackend) PSCAddress() common.Address
PSCAddress is mock to PSCAddress.
func (*TestEthBackend) PSCBalanceOf ¶
PSCBalanceOf is mock to PSCBalanceOf.
func (*TestEthBackend) PSCCreateChannel ¶
func (b *TestEthBackend) PSCCreateChannel(opts *bind.TransactOpts, agent common.Address, hash [common.HashLength]byte, deposit uint64) (*types.Transaction, error)
PSCCreateChannel is mock to PSCCreateChannel.
func (*TestEthBackend) PSCGetChannelInfo ¶
func (b *TestEthBackend) PSCGetChannelInfo(opts *bind.CallOpts, client common.Address, agent common.Address, blockNumber uint32, hash [common.HashLength]byte) (uint64, uint32, uint64, error)
PSCGetChannelInfo is mock to PSCGetChannelInfo.
func (*TestEthBackend) PSCGetOfferingInfo ¶
func (b *TestEthBackend) PSCGetOfferingInfo(opts *bind.CallOpts, hash [common.HashLength]byte) (agentAddr common.Address, minDeposit uint64, maxSupply uint16, currentSupply uint16, updateBlockNumber uint32, active bool, err error)
PSCGetOfferingInfo is mock to PSCGetOfferingInfo.
func (*TestEthBackend) PSCPopupServiceOffering ¶
func (b *TestEthBackend) PSCPopupServiceOffering(opts *bind.TransactOpts, offeringHash [32]byte, somcType uint8, somcData data.Base64String) (*types.Transaction, error)
PSCPopupServiceOffering is mock to PSCPopupServiceOffering.
func (*TestEthBackend) PSCRemoveServiceOffering ¶
func (b *TestEthBackend) PSCRemoveServiceOffering(opts *bind.TransactOpts, offeringHash [32]byte) (*types.Transaction, error)
PSCRemoveServiceOffering is mock to PSCRemoveServiceOffering.
func (*TestEthBackend) PSCReturnBalanceERC20 ¶
func (b *TestEthBackend) PSCReturnBalanceERC20(opts *bind.TransactOpts, val uint64) (*types.Transaction, error)
PSCReturnBalanceERC20 is mock to PSCReturnBalanceERC20.
func (*TestEthBackend) PSCSettle ¶
func (b *TestEthBackend) PSCSettle(opts *bind.TransactOpts, agent common.Address, blockNumber uint32, hash [common.HashLength]byte) (*types.Transaction, error)
PSCSettle is mock to PSCSettle.
func (*TestEthBackend) PSCTopUpChannel ¶
func (b *TestEthBackend) PSCTopUpChannel(opts *bind.TransactOpts, agent common.Address, blockNumber uint32, hash [common.HashLength]byte, deposit uint64) (*types.Transaction, error)
PSCTopUpChannel is mock to PSCTopUpChannel.
func (*TestEthBackend) PSCUncooperativeClose ¶
func (b *TestEthBackend) PSCUncooperativeClose(opts *bind.TransactOpts, agent common.Address, blockNumber uint32, hash [common.HashLength]byte, balance uint64) (*types.Transaction, error)
PSCUncooperativeClose is mock to PSCUncooperativeClose.
func (*TestEthBackend) PTCAddress ¶
func (b *TestEthBackend) PTCAddress() common.Address
PTCAddress is mock to PTCAddress.
func (*TestEthBackend) PTCBalanceOf ¶
PTCBalanceOf is mock to PTCBalanceOf.
func (*TestEthBackend) PTCIncreaseApproval ¶
func (b *TestEthBackend) PTCIncreaseApproval(opts *bind.TransactOpts, addr common.Address, amount *big.Int) (*types.Transaction, error)
PTCIncreaseApproval is mock to PTCIncreaseApproval.
func (*TestEthBackend) PendingNonceAt ¶
func (b *TestEthBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
PendingNonceAt returns the account nonce of the given account in the pending state. This is the nonce that should be used for the next transaction.
func (*TestEthBackend) RegisterServiceOffering ¶
func (b *TestEthBackend) RegisterServiceOffering(opts *bind.TransactOpts, offeringHash [32]byte, minDeposit uint64, maxSupply uint16, somcData uint8, somcType data.Base64String) (*types.Transaction, error)
RegisterServiceOffering is mock to RegisterServiceOffering.
func (*TestEthBackend) SetTransaction ¶
func (b *TestEthBackend) SetTransaction(t *testing.T, opts *bind.TransactOpts, input []byte)
SetTransaction mocks return value for GetTransactionByHash.
func (*TestEthBackend) SuggestGasPrice ¶
SuggestGasPrice is mock to SuggestGasPrice.
func (*TestEthBackend) TestCalled ¶
func (b *TestEthBackend) TestCalled(t *testing.T, method string, caller common.Address, gasLimit uint64, args ...interface{})
TestCalled tests the existence of a Ethereum call.