testdb

package
v0.0.0-...-477d63b Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const OMIT_FIELD = "OMIT_FIELD"

Variables

This section is empty.

Functions

func CallFail

func CallFail(t *testing.T, url string, msg ...string)

func CallJSON

func CallJSON(t *testing.T, url string) (body []byte)

Make an HTTP call to the /v1 api, return the body which can be parsed as a JSON.

func DeclarePools

func DeclarePools(pools ...string)

func DeleteTables

func DeleteTables(t *testing.T)

func HideTestLogs

func HideTestLogs(t *testing.T)

Show test logs only on failure

func InitTest

func InitTest(t *testing.T)

func InitTestBlocks

func InitTestBlocks(t *testing.T) *blockCreator

Use this when full blocks are added.

func InsertBlockLog

func InsertBlockLog(t *testing.T, height int64, fakeTimestamp string) (hash string)

func InsertBlockPoolDepth

func InsertBlockPoolDepth(t *testing.T, pool string, assetE8, runeE8 int64, blockTimestamp string)

func InsertBondEvent

func InsertBondEvent(t *testing.T, fake FakeBond)

func InsertMintBurnEvent

func InsertMintBurnEvent(t *testing.T, fake FakeMintBurn)

func InsertPoolEvents

func InsertPoolEvents(t *testing.T, pool, status string)

func InsertRewardsEvent

func InsertRewardsEvent(t *testing.T, bondE8 int64, fakeTimestamp string)

func InsertRewardsEventEntry

func InsertRewardsEventEntry(t *testing.T, bondE8 int64, pool, fakeTimestamp string)

func InsertStakeEvent

func InsertStakeEvent(t *testing.T, fake FakeStake)

func InsertSwapEvent

func InsertSwapEvent(t *testing.T, fake FakeSwap)

func InsertSwitchEvent

func InsertSwitchEvent(t *testing.T, fake FakeSwitch)

func InsertUpdateNodeAccountStatusEvent

func InsertUpdateNodeAccountStatusEvent(t *testing.T, fake FakeNodeStatus, blockTimestamp string)

func InsertWithdrawEvent

func InsertWithdrawEvent(t *testing.T, fake FakeWithdraw)

func JSONFailGeneral

func JSONFailGeneral(t *testing.T, url string)

func MustExec

func MustExec(t *testing.T, query string, args ...interface{})

Execute a query on the database.

func MustUnmarshal

func MustUnmarshal(t *testing.T, data []byte, v interface{})

func RegisterThornodeNodes

func RegisterThornodeNodes(nodeAccounts []notinchain.NodeAccount)

func RegisterThornodeReserve

func RegisterThornodeReserve(totalReserve int64)

func RoughlyEqual

func RoughlyEqual(t *testing.T, expected float64, actual string)

func ScenarioTenSwaps

func ScenarioTenSwaps(t *testing.T, blocks *blockCreator)

A test scenario with 10 swaps 4x rune -> asset: volume 40, fee 4, slip 5 3x asset -> rune: volume 3000 + 300, fee 300, slip 6 2x rune -> synth: volume 200000, fee 20000, slip 7 1x synth -> rune: volume 10000000 + 1000000, fee 1000000, slip 8

func SecToString

func SecToString(s db.Second) string

func SetThornodeConstant

func SetThornodeConstant(t *testing.T, name string, value int64, timestamp string)

func SetupTestDB

func SetupTestDB(t *testing.T)

func StartMockThornode

func StartMockThornode() (deactivateCallback func())

Starts Thornode HTTP mock with some simiple / empty results.

func StrToNano

func StrToNano(s string) db.Nano

Types

type ActiveVault

type ActiveVault struct {
	AddVault string
}

func (ActiveVault) ToTendermint

func (x ActiveVault) ToTendermint() abci.Event

type AddLiquidity

type AddLiquidity struct {
	Pool                   string
	AssetAmount            int64
	RuneAmount             int64
	AssetAddress           string
	RuneAddress            string
	RuneTxID               string
	AssetTxID              string
	LiquidityProviderUnits int64 // If 0 defaults to 1
}

func (AddLiquidity) ToTendermint

func (x AddLiquidity) ToTendermint() abci.Event

type Amount

type Amount struct {
	Asset string
	E8    int64
}
type Donate struct {
	Chain       string
	Coin        string
	FromAddress string
	ToAddress   string
	TxID        string
	Memo        string
	Pool        string
}

func (Donate) ToTendermint

func (x Donate) ToTendermint() abci.Event

type FakeBond

type FakeBond struct {
	Tx             string
	Chain          string
	FromAddr       string
	ToAddr         string
	Asset          string
	AssetE8        int64 // Asset quantity times 100 M
	Memo           string
	BondType       string
	E8             int64
	BlockTimestamp string
}

type FakeEvent

type FakeEvent interface {
	ToTendermint() abci.Event
}

type FakeMintBurn

type FakeMintBurn struct {
	Asset          string
	AssetE8        int64
	Supply         string
	Reason         string
	BlockTimestamp string
}

type FakeNodeStatus

type FakeNodeStatus struct {
	NodeAddr string
	Former   string
	Current  string
}

type FakeStake

type FakeStake struct {
	Pool           string
	BlockTimestamp string
	AssetE8        int64
	AssetInRuneE8  int64
	RuneE8         int64
	StakeUnits     int64
	RuneAddress    string
	AssetAddress   string
	AssetTx        string
	RuneTx         string
}

type FakeSwap

type FakeSwap struct {
	Tx             string
	Pool           string
	FromAsset      string
	FromE8         int64
	FromAddr       string
	ToE8           int64
	ToAddr         string
	LiqFeeInRuneE8 int64
	LiqFeeE8       int64
	SwapSlipBP     int64
	ToE8Min        int64
	BlockTimestamp string
}

TODO(muninn): Remove, migrate remaining tests to FakeBlocks.

type FakeSwitch

type FakeSwitch struct {
	FromAddr       string
	ToAddr         string
	BurnAsset      string
	BurnE8         int64
	BlockTimestamp string
}

type FakeWithdraw

type FakeWithdraw struct {
	Asset               string
	FromAddr            string
	ToAddr              string
	BlockTimestamp      string
	StakeUnits          int64
	Pool                string
	EmitAssetE8         int64
	EmitAssetInRuneE8   int64
	EmitRuneE8          int64
	ImpLossProtectionE8 int64
}

type Fee

type Fee struct {
	TxID       string
	Coins      string
	PoolDeduct int64
}

func (Fee) ToTendermint

func (x Fee) ToTendermint() abci.Event

type LoanOpen

type LoanOpen struct {
	Owner                  string
	CollateralUp           int64
	DebtUpTor              int64
	CollateralAsset        string
	CollateralizationRatio int64
	TargetAsset            string
}

func (LoanOpen) ToTendermint

func (x LoanOpen) ToTendermint() abci.Event

type LoanOpenV118

type LoanOpenV118 struct {
	Owner                  string
	CollateralDeposited    int64
	DebtIssuedTor          int64
	CollateralAsset        string
	CollateralizationRatio int64
	TargetAsset            string
}

func (LoanOpenV118) ToTendermint

func (x LoanOpenV118) ToTendermint() abci.Event

type LoanRepayment

type LoanRepayment struct {
	Owner           string
	CollateralDown  int64
	DebtDownTor     int64
	CollateralAsset string
}

func (LoanRepayment) ToTendermint

func (x LoanRepayment) ToTendermint() abci.Event

type LoanRepaymentV118

type LoanRepaymentV118 struct {
	Owner               string
	CollateralWithdrawn int64
	DebtRepaidTor       int64
	CollateralAsset     string
}

func (LoanRepaymentV118) ToTendermint

func (x LoanRepaymentV118) ToTendermint() abci.Event

type Outbound

type Outbound struct {
	Chain       string
	Coin        string
	FromAddress string
	ToAddress   string
	TxID        string
	InTxID      string
	Memo        string
}

func (Outbound) ToTendermint

func (x Outbound) ToTendermint() abci.Event

type PendingLiquidity

type PendingLiquidity struct {
	Pool         string
	AssetAmount  int64
	RuneAmount   int64
	AssetAddress string
	RuneAddress  string
	RuneTxID     string
	AssetTxID    string
	PendingType  PendingTypeEnum
}

Note that this intentionally doesn't have a base class together with AddLiquidity. Unfortunately initializing fields of embedded structs is cumbersome, it would make writing the unit tests harder.

func (PendingLiquidity) ToTendermint

func (x PendingLiquidity) ToTendermint() abci.Event

type PendingTypeEnum

type PendingTypeEnum int
const (
	PendingAdd PendingTypeEnum = iota
	PendingWithdraw
)

type PoolStatus

type PoolStatus struct {
	Pool   string
	Status StatusName
}

func PoolActivate

func PoolActivate(pool string) PoolStatus

func (PoolStatus) ToTendermint

func (x PoolStatus) ToTendermint() abci.Event

type Refund

type Refund struct {
	TxID        string
	Chain       string
	Coin        string
	FromAddress string
	ToAddress   string
	Reason      string
	Memo        string
}

func (Refund) ToTendermint

func (x Refund) ToTendermint() abci.Event

type Rewards

type Rewards struct {
	BondE8  int64
	PerPool []Amount
}

func (Rewards) ToTendermint

func (x Rewards) ToTendermint() abci.Event

type ScheduledOutbound

type ScheduledOutbound struct {
	Chain         string
	CoinAmount    string
	CoinAsset     string
	CoinDecimals  string
	GasRate       string
	MaxGasAmount  []string
	MaxGasAsset   []string
	MaxGasDecimal []string
	ModuleName    string
	OutHash       string
	ToAddress     string
	InHash        string
	Memo          string
	VaultPubKey   string
}

func (ScheduledOutbound) ToTendermint

func (x ScheduledOutbound) ToTendermint() abci.Event

type SetMimir

type SetMimir struct {
	Key   string
	Value int64
}

func (SetMimir) ToTendermint

func (x SetMimir) ToTendermint() abci.Event

type StatusName

type StatusName string
const (
	StatusAvailable StatusName = "available"
	StatusSuspended StatusName = "suspended"
	StatusStaged    StatusName = "staged"
)

type StreamingSwapDetails

type StreamingSwapDetails struct {
	TxID       string
	Interval   int64
	Quantity   int64
	Count      int64
	LastHeight int64
	Deposit    string
	In         string
	Out        string
}

func (StreamingSwapDetails) ToTendermint

func (x StreamingSwapDetails) ToTendermint() abci.Event

type Swap

type Swap struct {
	Pool               string
	Coin               string
	EmitAsset          string
	LiquidityFee       int64
	LiquidityFeeInRune int64
	Slip               int64
	FromAddress        string
	ToAddress          string
	TxID               string
	PriceTarget        int64
	Memo               string
	StreamingCount     int64
	StreamingQuantity  int64
}

func (Swap) ToTendermint

func (x Swap) ToTendermint() abci.Event

type Switch

type Switch struct {
	FromAddress string
	ToAddress   string
	Burn        string
	Mint        int64 // Omitted if 0
	TxID        string
}

func (Switch) ToTendermint

func (x Switch) ToTendermint() abci.Event

type THORName

type THORName struct {
	Name            string
	Chain           string
	Address         string
	RegistrationFee int64
	FundAmount      int64
	ExpireHeight    int64
	Owner           string
}

func (THORName) ToTendermint

func (x THORName) ToTendermint() abci.Event

type Transfer

type Transfer struct {
	FromAddr    string
	ToAddr      string
	AssetAmount string
}

func (Transfer) ToTendermint

func (x Transfer) ToTendermint() abci.Event

type UpdateNodeAccountStatus

type UpdateNodeAccountStatus struct {
	NodeAddr string
	Former   string
	Current  string
}

func (UpdateNodeAccountStatus) ToTendermint

func (x UpdateNodeAccountStatus) ToTendermint() abci.Event

type Version

type Version struct {
	Version string
}

func (Version) ToTendermint

func (x Version) ToTendermint() abci.Event

type Withdraw

type Withdraw struct {
	Pool                   string
	Coin                   string
	EmitAsset              int64
	EmitRune               int64
	LiquidityProviderUnits int64
	ImpLossProtection      int64
	ToAddress              string
	FromAddress            string
	ID                     string
	Asymmetry              string
	BasisPoints            int64
}

func (Withdraw) ToTendermint

func (x Withdraw) ToTendermint() abci.Event

Jump to

Keyboard shortcuts

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