lnwallet: convert interface-level tests to be run as sub-tests

This commit is contained in:
Olaoluwa Osuntokun 2017-07-29 18:48:01 -07:00
parent 9c0261206d
commit e930af4b43
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -1233,22 +1233,45 @@ func testSignOutputPrivateTweak(r *rpctest.Harness, w *lnwallet.LightningWallet,
} }
} }
var walletTests = []func(miner *rpctest.Harness, w *lnwallet.LightningWallet, test *testing.T){ type walletTestCase struct {
// TODO(roasbeef): reservation tests should prob be split out name string
testDualFundingReservationWorkflow, test func(miner *rpctest.Harness, alice, bob *lnwallet.LightningWallet,
testSingleFunderReservationWorkflowInitiator, test *testing.T)
testSingleFunderReservationWorkflowResponder,
testFundingTransactionLockedOutputs,
testFundingCancellationNotEnoughFunds,
testTransactionSubscriptions,
testListTransactionDetails,
testSignOutputPrivateTweak,
testCancelNonExistantReservation,
} }
type testLnWallet struct { var walletTests = []walletTestCase{
lnwallet *lnwallet.LightningWallet {
cleanUpFunc func() name: "single funding workflow",
test: testSingleFunderReservationWorkflow,
},
{
name: "dual funder workflow",
test: testDualFundingReservationWorkflow,
},
{
name: "output locking",
test: testFundingTransactionLockedOutputs,
},
{
name: "reservation insufficient funds",
test: testFundingCancellationNotEnoughFunds,
},
{
name: "transaction subscriptions",
test: testTransactionSubscriptions,
},
{
name: "transaction details",
test: testListTransactionDetails,
},
{
name: "signed with tweaked pubkeys",
test: testSignOutputUsingTweaks,
},
{
name: "test cancel non-existent reservation",
test: testCancelNonExistantReservation,
},
} }
func clearWalletState(w *lnwallet.LightningWallet) error { func clearWalletState(w *lnwallet.LightningWallet) error {
@ -1357,8 +1380,14 @@ func TestLightningWallet(t *testing.T) {
// Execute every test, clearing possibly mutated wallet state after // Execute every test, clearing possibly mutated wallet state after
// each step. // each step.
for _, walletTest := range walletTests { for _, walletTest := range walletTests {
// TODO(roasbeef): run as parallel sub-tests? testName := fmt.Sprintf("%v:%v", walletType,
walletTest(miningNode, lnw, t) walletTest.name)
success := t.Run(testName, func(t *testing.T) {
walletTest.test(miningNode, alice, bob, t)
})
if !success {
break
}
// TODO(roasbeef): possible reset mining node's // TODO(roasbeef): possible reset mining node's
// chainstate to initial level, cleanly wipe buckets // chainstate to initial level, cleanly wipe buckets