Annotate paych tests
This commit is contained in:
parent
a64f2421d2
commit
0f83a0a634
@ -44,6 +44,9 @@ func TestCheckVoucherValid(t *testing.T) {
|
|||||||
mock.setAccountAddress(fromAcct, from)
|
mock.setAccountAddress(fromAcct, from)
|
||||||
mock.setAccountAddress(toAcct, to)
|
mock.setAccountAddress(toAcct, to)
|
||||||
|
|
||||||
|
//stm: @TOKEN_PAYCH_VOUCHER_VALID_001, @TOKEN_PAYCH_VOUCHER_VALID_002, @TOKEN_PAYCH_VOUCHER_VALID_003
|
||||||
|
//stm: @TOKEN_PAYCH_VOUCHER_VALID_004, @TOKEN_PAYCH_VOUCHER_VALID_005, @TOKEN_PAYCH_VOUCHER_VALID_006, @TOKEN_PAYCH_VOUCHER_VALID_007
|
||||||
|
//stm: @TOKEN_PAYCH_VOUCHER_VALID_009, @TOKEN_PAYCH_VOUCHER_VALID_010
|
||||||
tcases := []struct {
|
tcases := []struct {
|
||||||
name string
|
name string
|
||||||
expectError bool
|
expectError bool
|
||||||
@ -243,6 +246,7 @@ func TestCreateVoucher(t *testing.T) {
|
|||||||
Lane: 1,
|
Lane: 1,
|
||||||
Amount: voucherLane1Amt,
|
Amount: voucherLane1Amt,
|
||||||
}
|
}
|
||||||
|
//stm: @TOKEN_PAYCH_VOUCHER_CREATE_001
|
||||||
res, err := s.mgr.CreateVoucher(ctx, s.ch, voucher)
|
res, err := s.mgr.CreateVoucher(ctx, s.ch, voucher)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, res.Voucher)
|
require.NotNil(t, res.Voucher)
|
||||||
@ -287,6 +291,7 @@ func TestCreateVoucher(t *testing.T) {
|
|||||||
Lane: 2,
|
Lane: 2,
|
||||||
Amount: voucherLane2Amt,
|
Amount: voucherLane2Amt,
|
||||||
}
|
}
|
||||||
|
//stm: @TOKEN_PAYCH_VOUCHER_CREATE_004
|
||||||
res, err = s.mgr.CreateVoucher(ctx, s.ch, voucher)
|
res, err = s.mgr.CreateVoucher(ctx, s.ch, voucher)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -297,6 +302,7 @@ func TestCreateVoucher(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAddVoucherDelta(t *testing.T) {
|
func TestAddVoucherDelta(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_LIST_VOUCHERS_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// Set up a manager with a single payment channel
|
// Set up a manager with a single payment channel
|
||||||
@ -358,6 +364,7 @@ func TestAddVoucherNextLane(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.EqualValues(t, ci.NextLane, 3)
|
require.EqualValues(t, ci.NextLane, 3)
|
||||||
|
|
||||||
|
//stm: @TOKEN_PAYCH_ALLOCATE_LANE_001
|
||||||
// Allocate a lane (should be lane 3)
|
// Allocate a lane (should be lane 3)
|
||||||
lane, err := s.mgr.AllocateLane(s.ch)
|
lane, err := s.mgr.AllocateLane(s.ch)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -392,6 +399,7 @@ func TestAllocateLane(t *testing.T) {
|
|||||||
// Set up a manager with a single payment channel
|
// Set up a manager with a single payment channel
|
||||||
s := testSetupMgrWithChannel(t)
|
s := testSetupMgrWithChannel(t)
|
||||||
|
|
||||||
|
//stm: @TOKEN_PAYCH_ALLOCATE_LANE_001
|
||||||
// First lane should be 0
|
// First lane should be 0
|
||||||
lane, err := s.mgr.AllocateLane(s.ch)
|
lane, err := s.mgr.AllocateLane(s.ch)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -446,6 +454,7 @@ func TestAllocateLaneWithExistingLaneState(t *testing.T) {
|
|||||||
_, err = mgr.AddVoucherInbound(ctx, ch, sv, nil, minDelta)
|
_, err = mgr.AddVoucherInbound(ctx, ch, sv, nil, minDelta)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
//stm: @TOKEN_PAYCH_ALLOCATE_LANE_001
|
||||||
// Allocate lane should return the next lane (lane 3)
|
// Allocate lane should return the next lane (lane 3)
|
||||||
lane, err := mgr.AllocateLane(ch)
|
lane, err := mgr.AllocateLane(ch)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -508,6 +517,7 @@ func TestAddVoucherInboundWalletKey(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBestSpendable(t *testing.T) {
|
func TestBestSpendable(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_LIST_VOUCHERS_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// Set up a manager with a single payment channel
|
// Set up a manager with a single payment channel
|
||||||
@ -550,6 +560,7 @@ func TestBestSpendable(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//stm: @TOKEN_PAYCH_BEST_SPENDABLE_001
|
||||||
// Verify best spendable vouchers on each lane
|
// Verify best spendable vouchers on each lane
|
||||||
vouchers, err := BestSpendableByLane(ctx, bsapi, s.ch)
|
vouchers, err := BestSpendableByLane(ctx, bsapi, s.ch)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -690,6 +701,7 @@ func TestSubmitVoucher(t *testing.T) {
|
|||||||
err = p3.UnmarshalCBOR(bytes.NewReader(msg.Message.Params))
|
err = p3.UnmarshalCBOR(bytes.NewReader(msg.Message.Params))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
//stm: @TOKEN_PAYCH_LIST_VOUCHERS_001
|
||||||
// Verify that vouchers are marked as submitted
|
// Verify that vouchers are marked as submitted
|
||||||
vis, err := s.mgr.ListVouchers(ctx, s.ch)
|
vis, err := s.mgr.ListVouchers(ctx, s.ch)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -68,6 +68,7 @@ func TestPaychGetCreateChannelMsg(t *testing.T) {
|
|||||||
// TestPaychGetCreateChannelThenAddFunds tests creating a channel and then
|
// TestPaychGetCreateChannelThenAddFunds tests creating a channel and then
|
||||||
// adding funds to it
|
// adding funds to it
|
||||||
func TestPaychGetCreateChannelThenAddFunds(t *testing.T) {
|
func TestPaychGetCreateChannelThenAddFunds(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -158,6 +159,7 @@ func TestPaychGetCreateChannelThenAddFunds(t *testing.T) {
|
|||||||
// operation is queued up behind a create channel operation, and the create
|
// operation is queued up behind a create channel operation, and the create
|
||||||
// channel fails, then the waiting operation can succeed.
|
// channel fails, then the waiting operation can succeed.
|
||||||
func TestPaychGetCreateChannelWithErrorThenCreateAgain(t *testing.T) {
|
func TestPaychGetCreateChannelWithErrorThenCreateAgain(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -222,6 +224,7 @@ func TestPaychGetCreateChannelWithErrorThenCreateAgain(t *testing.T) {
|
|||||||
// TestPaychGetRecoverAfterError tests that after a create channel fails, the
|
// TestPaychGetRecoverAfterError tests that after a create channel fails, the
|
||||||
// next attempt to create channel can succeed.
|
// next attempt to create channel can succeed.
|
||||||
func TestPaychGetRecoverAfterError(t *testing.T) {
|
func TestPaychGetRecoverAfterError(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -274,6 +277,7 @@ func TestPaychGetRecoverAfterError(t *testing.T) {
|
|||||||
// TestPaychGetRecoverAfterAddFundsError tests that after an add funds fails, the
|
// TestPaychGetRecoverAfterAddFundsError tests that after an add funds fails, the
|
||||||
// next attempt to add funds can succeed.
|
// next attempt to add funds can succeed.
|
||||||
func TestPaychGetRecoverAfterAddFundsError(t *testing.T) {
|
func TestPaychGetRecoverAfterAddFundsError(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -356,6 +360,7 @@ func TestPaychGetRecoverAfterAddFundsError(t *testing.T) {
|
|||||||
// right after the create channel message is sent, the channel will be
|
// right after the create channel message is sent, the channel will be
|
||||||
// created when the system restarts.
|
// created when the system restarts.
|
||||||
func TestPaychGetRestartAfterCreateChannelMsg(t *testing.T) {
|
func TestPaychGetRestartAfterCreateChannelMsg(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -435,6 +440,7 @@ func TestPaychGetRestartAfterCreateChannelMsg(t *testing.T) {
|
|||||||
// right after the add funds message is sent, the add funds will be
|
// right after the add funds message is sent, the add funds will be
|
||||||
// processed when the system restarts.
|
// processed when the system restarts.
|
||||||
func TestPaychGetRestartAfterAddFundsMsg(t *testing.T) {
|
func TestPaychGetRestartAfterAddFundsMsg(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -498,6 +504,7 @@ func TestPaychGetRestartAfterAddFundsMsg(t *testing.T) {
|
|||||||
// TestPaychGetWait tests that GetPaychWaitReady correctly waits for the
|
// TestPaychGetWait tests that GetPaychWaitReady correctly waits for the
|
||||||
// channel to be created or funds to be added
|
// channel to be created or funds to be added
|
||||||
func TestPaychGetWait(t *testing.T) {
|
func TestPaychGetWait(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -555,6 +562,7 @@ func TestPaychGetWait(t *testing.T) {
|
|||||||
|
|
||||||
// TestPaychGetWaitErr tests that GetPaychWaitReady correctly handles errors
|
// TestPaychGetWaitErr tests that GetPaychWaitReady correctly handles errors
|
||||||
func TestPaychGetWaitErr(t *testing.T) {
|
func TestPaychGetWaitErr(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -602,6 +610,7 @@ func TestPaychGetWaitErr(t *testing.T) {
|
|||||||
// TestPaychGetWaitCtx tests that GetPaychWaitReady returns early if the context
|
// TestPaychGetWaitCtx tests that GetPaychWaitReady returns early if the context
|
||||||
// is cancelled
|
// is cancelled
|
||||||
func TestPaychGetWaitCtx(t *testing.T) {
|
func TestPaychGetWaitCtx(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -631,6 +640,7 @@ func TestPaychGetWaitCtx(t *testing.T) {
|
|||||||
// progress and two add funds are queued up behind it, the two add funds
|
// progress and two add funds are queued up behind it, the two add funds
|
||||||
// will be merged
|
// will be merged
|
||||||
func TestPaychGetMergeAddFunds(t *testing.T) {
|
func TestPaychGetMergeAddFunds(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -729,6 +739,7 @@ func TestPaychGetMergeAddFunds(t *testing.T) {
|
|||||||
// TestPaychGetMergeAddFundsCtxCancelOne tests that when a queued add funds
|
// TestPaychGetMergeAddFundsCtxCancelOne tests that when a queued add funds
|
||||||
// request is cancelled, its amount is removed from the total merged add funds
|
// request is cancelled, its amount is removed from the total merged add funds
|
||||||
func TestPaychGetMergeAddFundsCtxCancelOne(t *testing.T) {
|
func TestPaychGetMergeAddFundsCtxCancelOne(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -826,6 +837,7 @@ func TestPaychGetMergeAddFundsCtxCancelOne(t *testing.T) {
|
|||||||
// TestPaychGetMergeAddFundsCtxCancelAll tests that when all queued add funds
|
// TestPaychGetMergeAddFundsCtxCancelAll tests that when all queued add funds
|
||||||
// requests are cancelled, no add funds message is sent
|
// requests are cancelled, no add funds message is sent
|
||||||
func TestPaychGetMergeAddFundsCtxCancelAll(t *testing.T) {
|
func TestPaychGetMergeAddFundsCtxCancelAll(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
@ -900,6 +912,7 @@ func TestPaychGetMergeAddFundsCtxCancelAll(t *testing.T) {
|
|||||||
// TestPaychAvailableFunds tests that PaychAvailableFunds returns the correct
|
// TestPaychAvailableFunds tests that PaychAvailableFunds returns the correct
|
||||||
// channel state
|
// channel state
|
||||||
func TestPaychAvailableFunds(t *testing.T) {
|
func TestPaychAvailableFunds(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_WAIT_READY_001, @TOKEN_PAYCH_AVAILABLE_FUNDS_001, @TOKEN_PAYCH_AVAILABLE_FUNDS_002, @TOKEN_PAYCH_AVAILABLE_FUNDS_003
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
// insufficient funds, then adding funds to the channel, then adding the
|
// insufficient funds, then adding funds to the channel, then adding the
|
||||||
// voucher again
|
// voucher again
|
||||||
func TestPaychAddVoucherAfterAddFunds(t *testing.T) {
|
func TestPaychAddVoucherAfterAddFunds(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPaychSettle(t *testing.T) {
|
func TestPaychSettle(t *testing.T) {
|
||||||
|
//stm: @TOKEN_PAYCH_WAIT_READY_001, @TOKEN_PAYCH_SETTLE_001, @TOKEN_PAYCH_LIST_CHANNELS_001
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user