diff --git a/test/simulation/actions.go b/test/simulation/actions.go index dac411f9d..93060d330 100644 --- a/test/simulation/actions.go +++ b/test/simulation/actions.go @@ -4,8 +4,8 @@ import ( "context" "errors" "fmt" - "github.com/ExchangeUnion/xud-simulation/connexttest" - "math/big" + // "github.com/ExchangeUnion/xud-simulation/connexttest" + // "math/big" "time" "github.com/roasbeef/btcutil" @@ -56,13 +56,14 @@ func (a *actions) init(node *xudtest.HarnessNode) { // Add currencies. a.addCurrency(node, "BTC", xudrpc.Currency_LND, "", 8) a.addCurrency(node, "LTC", xudrpc.Currency_LND, "", 8) - a.addCurrency(node, "ETH", xudrpc.Currency_CONNEXT, connexttest.ETHTokenAddress, 18) + // a.addCurrency(node, "ETH", xudrpc.Currency_CONNEXT, connexttest.ETHTokenAddress, 18) // Add pairs. a.addPair(node, "LTC", "BTC") - a.addPair(node, "BTC", "ETH") + // a.addPair(node, "BTC", "ETH") } +/* func (a *actions) FundETH(net *xudtest.NetworkHarness, node *xudtest.HarnessNode) { // Wait for node's connext connection to catch-up. a.waitConnextReady(node) @@ -84,6 +85,7 @@ func (a *actions) FundETH(net *xudtest.NetworkHarness, node *xudtest.HarnessNode a.assert.Equal(uint64(200000000), ethBal.WalletBalance) a.assert.Equal(uint64(0), ethBal.ChannelBalance) } +*/ func (a *actions) waitConnextReady(node *xudtest.HarnessNode) { isReady := func() bool { diff --git a/test/simulation/docker-build.sh b/test/simulation/docker-build.sh index da4a704c1..4b94b096a 100755 --- a/test/simulation/docker-build.sh +++ b/test/simulation/docker-build.sh @@ -1,14 +1,15 @@ #!/usr/bin/env bash -if [[ $@ == "connext" || $# == 0 ]] -then - mkdir -p temp - pushd temp - git clone https://github.com/ConnextProject/indra.git - cd indra - git checkout indra-7.3.14 - make - popd -fi +# TODO(karl): enable connext V2 simulation tests +# if [[ $@ == "connext" || $# == 0 ]] +# then + # mkdir -p temp + # pushd temp + # git clone https://github.com/ConnextProject/indra.git + # cd indra + # git checkout indra-7.3.14 + # make + # popd +# fi docker-compose build $@ diff --git a/test/simulation/docker-compose.yml b/test/simulation/docker-compose.yml index c40cb107a..0719b9b47 100644 --- a/test/simulation/docker-compose.yml +++ b/test/simulation/docker-compose.yml @@ -8,10 +8,10 @@ services: build: ./docker-lnd volumes: - lnd-vol:/app - connext: - build: ./docker-connext - volumes: - - connext-vol:/app + # connext: + # build: ./docker-connext + # volumes: + # - connext-vol:/app xud: build: ./docker-xud volumes: @@ -29,13 +29,13 @@ services: depends_on: - btcd - lnd - - connext + # - connext - xud - gomod volumes: - btcd-vol:/btcd-vol - lnd-vol:/lnd-vol - - connext-vol:/connext-vol + # - connext-vol:/connext-vol - xud-vol:/xud-vol - custom-xud-vol:/custom-xud-vol - nvm-vol:/nvm-vol @@ -43,12 +43,12 @@ services: volumes: btcd-vol: lnd-vol: - connext-vol: + # connext-vol: xud-vol: custom-xud-vol: nvm-vol: gomod-vol: -networks: - default: - external: - name: indra + # networks: + # default: + # external: + # name: indra diff --git a/test/simulation/docker-run.sh b/test/simulation/docker-run.sh index 852371aef..0fef13519 100755 --- a/test/simulation/docker-run.sh +++ b/test/simulation/docker-run.sh @@ -2,11 +2,11 @@ # create the temp directories with the current user so it is the owner for permissions mkdir -p $PWD/temp/logs -mkdir -p $PWD/temp/indra +# mkdir -p $PWD/temp/indra -pushd temp/indra -make start -popd +# pushd temp/indra +# make start +# popd export DOCKER_CLIENT_TIMEOUT=120 export COMPOSE_HTTP_TIMEOUT=120 @@ -27,8 +27,8 @@ if [[ $testRetCode != 0 ]]; then done fi -pushd temp/indra -make reset -popd +# pushd temp/indra +# make reset +# popd exit $testRetCode diff --git a/test/simulation/tests-instability.go b/test/simulation/tests-instability.go index 7c2ece779..41b9d8fee 100644 --- a/test/simulation/tests-instability.go +++ b/test/simulation/tests-instability.go @@ -22,57 +22,28 @@ var instabilityTestCases = []*testCase{ name: "maker crashed after send payment before preimage resolved; incoming: lnd, outgoing: lnd", // replacing Alice test: testMakerCrashedAfterSendBeforePreimageResolved, }, - { - name: "maker crashed after send payment before preimage resolved; incoming: connext, outgoing: lnd", // replacing Alice - test: testMakerCrashedAfterSendBeforePreimageResolvedConnextIn, - }, { name: "maker crashed after send payment after preimage resolved; incoming: lnd, outgoing: lnd", // replacing Alice test: testMakerCrashedAfterSendAfterPreimageResolved, }, - { - name: "maker crashed after send payment after preimage resolved; incoming: connext, outgoing: lnd", // replacing Alice - test: testMakerCrashedAfterSendAfterPreimageResolvedConnextIn, - }, { name: "maker lnd crashed before order settlement", // replacing Alice test: testMakerLndCrashedBeforeSettlement, }, - { - name: "maker connext client crashed before order settlement", // replacing Alice - test: testMakerConnextClientCrashedBeforeSettlement, - }, { name: "maker crashed after send payment with delayed settlement; incoming: lnd, outgoing: lnd", // replacing Alice + Bob test: testMakerCrashedAfterSendDelayedSettlement, }, - { - name: "maker crashed after send payment with delayed settlement; incoming: connext, outgoing: lnd", // replacing Alice + Bob - test: testMakerCrashedAfterSendDelayedSettlementConnextIn, - }, - { - name: "maker crashed after send payment with delayed settlement; incoming: lnd, outgoing: connext", // replacing Alice + Bob - test: testMakerCrashedAfterSendDelayedSettlementConnextOut, - }, } func testMakerCrashedAfterSendBeforePreimageResolved(net *xudtest.NetworkHarness, ht *harnessTest) { testMakerCrashedDuringSwap(net, ht, []string{"CUSTOM_SCENARIO=INSTABILITY::MAKER_CRASH_AFTER_SEND_BEFORE_PREIMAGE_RESOLVED"}) } -func testMakerCrashedAfterSendBeforePreimageResolvedConnextIn(net *xudtest.NetworkHarness, ht *harnessTest) { - ht.act.FundETH(net, net.Bob) - testMakerCrashedDuringSwapConnextIn(net, ht, []string{"CUSTOM_SCENARIO=INSTABILITY::MAKER_CRASH_AFTER_SEND_BEFORE_PREIMAGE_RESOLVED"}) -} - func testMakerCrashedAfterSendAfterPreimageResolved(net *xudtest.NetworkHarness, ht *harnessTest) { testMakerCrashedDuringSwap(net, ht, []string{"CUSTOM_SCENARIO=INSTABILITY::MAKER_CRASH_AFTER_SEND_AFTER_PREIMAGE_RESOLVED"}) } -func testMakerCrashedAfterSendAfterPreimageResolvedConnextIn(net *xudtest.NetworkHarness, ht *harnessTest) { - testMakerCrashedDuringSwapConnextIn(net, ht, []string{"CUSTOM_SCENARIO=INSTABILITY::MAKER_CRASH_AFTER_SEND_AFTER_PREIMAGE_RESOLVED"}) -} - func testMakerCrashedDuringSwap(net *xudtest.NetworkHarness, ht *harnessTest, customXudMakerEnvVars []string) { var err error net.Alice, err = net.SetCustomXud(ht.ctx, ht, net.Alice, customXudMakerEnvVars) @@ -125,67 +96,6 @@ func testMakerCrashedDuringSwap(net *xudtest.NetworkHarness, ht *harnessTest, cu ht.assert.Equal(alicePrevLtcBalance+ltcQuantity, aliceLtcBalance, "alice did not receive LTC") } -func testMakerCrashedDuringSwapConnextIn(net *xudtest.NetworkHarness, ht *harnessTest, makerEnvArgs []string) { - var err error - net.Alice, err = net.SetCustomXud(ht.ctx, ht, net.Alice, makerEnvArgs) - ht.assert.NoError(err) - ht.act.init(net.Alice) - ht.act.waitConnextReady(net.Alice) - - // Connect Alice to Bob. - ht.act.connect(net.Alice, net.Bob) - ht.act.verifyConnectivity(net.Alice, net.Bob) - - err = openETHChannel(ht.ctx, net.Bob, 40000, 0) - ht.assert.NoError(err) - - // Save the initial balances. - alicePrevBalance, err := net.Alice.Client.GetBalance(ht.ctx, &xudrpc.GetBalanceRequest{Currency: "ETH"}) - ht.assert.NoError(err) - alicePrevEthBalance := alicePrevBalance.Balances["ETH"] - - // Place an order on Alice. - aliceOrderReq := &xudrpc.PlaceOrderRequest{ - OrderId: "testMakerCrashedDuringSwapConnextIn", - Price: 40, - Quantity: 100, - PairId: "BTC/ETH", - Side: xudrpc.OrderSide_SELL, - } - ht.act.placeOrderAndBroadcast(net.Alice, net.Bob, aliceOrderReq) - - // brief wait for collateralization to complete for Alice - time.Sleep(1 * time.Second) - - // Place a matching order on Bob. - bobOrderReq := &xudrpc.PlaceOrderRequest{ - OrderId: "testMakerCrashedDuringSwapConnextIn", - Price: aliceOrderReq.Price, - Quantity: aliceOrderReq.Quantity, - PairId: aliceOrderReq.PairId, - Side: xudrpc.OrderSide_BUY, - } - - _, err = net.Bob.Client.PlaceOrderSync(ht.ctx, bobOrderReq) - ht.assert.NoError(err) - - <-net.Alice.ProcessExit - - err = net.Alice.Start(nil) - ht.assert.NoError(err) - ht.act.waitConnextReady(net.Alice) - - // Brief delay to allow for swap to be recovered consistently. - time.Sleep(3 * time.Second) - - // Verify that Alice recovered ETH funds. - aliceBalance, err := net.Alice.Client.GetBalance(ht.ctx, &xudrpc.GetBalanceRequest{Currency: "ETH"}) - ht.assert.NoError(err) - aliceEthBalance := aliceBalance.Balances["ETH"] - diff := uint64(float64(aliceOrderReq.Quantity) * aliceOrderReq.Price) - ht.assert.Equal(alicePrevEthBalance.ChannelBalance+diff, aliceEthBalance.ChannelBalance, "alice did not recover ETH funds") -} - func testMakerLndCrashedBeforeSettlement(net *xudtest.NetworkHarness, ht *harnessTest) { var err error net.Alice, err = net.SetCustomXud(ht.ctx, ht, net.Alice, []string{ @@ -247,89 +157,6 @@ func testMakerLndCrashedBeforeSettlement(net *xudtest.NetworkHarness, ht *harnes ht.assert.Equal(alicePrevLtcBalance+ltcQuantity, aliceLtcBalance, "alice did not recover LTC funds") } -func testMakerConnextClientCrashedBeforeSettlement(net *xudtest.NetworkHarness, ht *harnessTest) { - var err error - net.Alice, err = net.SetCustomXud(ht.ctx, ht, net.Alice, []string{ - "CUSTOM_SCENARIO=INSTABILITY::MAKER_CLIENT_CRASHED_BEFORE_SETTLE", - "CLIENT_TYPE=ConnextClient", - // connext-client should be replaced, so we're not specifying its current PID, - // as in other client types. - }) - - ht.assert.NoError(err) - ht.act.init(net.Alice) - ht.act.waitConnextReady(net.Alice) - ht.act.waitConnextReady(net.Bob) - - // Connect Alice to Bob. - ht.act.connect(net.Alice, net.Bob) - ht.act.verifyConnectivity(net.Alice, net.Bob) - - err = openETHChannel(ht.ctx, net.Bob, 40000, 0) - ht.assert.NoError(err) - - // Save the initial balances. - alicePrevBalance, err := net.Alice.Client.GetBalance(ht.ctx, &xudrpc.GetBalanceRequest{Currency: "ETH"}) - ht.assert.NoError(err) - alicePrevEthBalance := alicePrevBalance.Balances["ETH"] - - bobPrevBalance, err := net.Bob.Client.GetBalance(ht.ctx, &xudrpc.GetBalanceRequest{Currency: "BTC"}) - ht.assert.NoError(err) - bobPrevBtcBalance := bobPrevBalance.Balances["BTC"] - - // Place an order on Alice. - aliceOrderReq := &xudrpc.PlaceOrderRequest{ - OrderId: "testMakerConnextClientCrashedBeforeSettlement", - Price: 40, - Quantity: 100, - PairId: "BTC/ETH", - Side: xudrpc.OrderSide_SELL, - } - ht.act.placeOrderAndBroadcast(net.Alice, net.Bob, aliceOrderReq) - - // brief wait for collateralization to complete for Alice - time.Sleep(1 * time.Second) - - // Place a matching order on Bob. - bobOrderReq := &xudrpc.PlaceOrderRequest{ - OrderId: "testMakerConnextClientCrashedBeforeSettlement", - Price: aliceOrderReq.Price, - Quantity: aliceOrderReq.Quantity, - PairId: aliceOrderReq.PairId, - Side: xudrpc.OrderSide_BUY, - } - go net.Bob.Client.PlaceOrderSync(ht.ctx, bobOrderReq) - - // Alice's connext-client is expected to be killed by Alice's custom xud. - <-net.Alice.ConnextClient.ProcessExit - - // Wait a bit so that Alice's call to connext-client for settlement would fail. - time.Sleep(5 * time.Second) - - // Restart Alice's connext-client. - err = net.Alice.ConnextClient.Start(nil) - ht.assert.NoError(err) - ht.act.waitConnextReady(net.Alice) - - // Brief delay to allow for swap to be recovered consistently. - // The pending swap recheck interval is usually 5m, but was adjusted in - // Alice's custom xud to 5s (as well as the swap completion timeout interval). - time.Sleep(10 * time.Second) - - // Verify that both parties received their payment. - bobBalance, err := net.Bob.Client.GetBalance(ht.ctx, &xudrpc.GetBalanceRequest{Currency: "BTC"}) - ht.assert.NoError(err) - bobBtcBalance := bobBalance.Balances["BTC"] - diff := bobOrderReq.Quantity - ht.assert.Equal(bobPrevBtcBalance.ChannelBalance+diff, bobBtcBalance.ChannelBalance) - - aliceBalance, err := net.Alice.Client.GetBalance(ht.ctx, &xudrpc.GetBalanceRequest{Currency: "ETH"}) - ht.assert.NoError(err) - aliceEthBalance := aliceBalance.Balances["ETH"] - diff = uint64(float64(aliceOrderReq.Quantity) * aliceOrderReq.Price) - ht.assert.Equal(alicePrevEthBalance.ChannelBalance+diff, aliceEthBalance.ChannelBalance, "alice did not recover ETH funds") -} - func testMakerCrashedAfterSendDelayedSettlement(net *xudtest.NetworkHarness, ht *harnessTest) { var err error net.Alice, err = net.SetCustomXud(ht.ctx, ht, net.Alice, []string{"CUSTOM_SCENARIO=INSTABILITY::MAKER_CRASH_WHILE_SENDING"}) @@ -401,7 +228,7 @@ func testMakerCrashedAfterSendDelayedSettlementConnextOut(net *xudtest.NetworkHa ht.assert.NoError(err) ht.act.init(net.Alice) - ht.act.FundETH(net, net.Alice) + // ht.act.FundETH(net, net.Alice) ht.act.init(net.Bob) ht.act.waitConnextReady(net.Bob) @@ -490,7 +317,7 @@ func testMakerCrashedAfterSendDelayedSettlementConnextIn(net *xudtest.NetworkHar ht.act.waitConnextReady(net.Alice) ht.act.init(net.Bob) - ht.act.FundETH(net, net.Bob) + // ht.act.FundETH(net, net.Bob) // Connect Alice to Bob. ht.act.connect(net.Alice, net.Bob) diff --git a/test/simulation/tests-integration.go b/test/simulation/tests-integration.go index 8c19a6eb2..05c6f334a 100644 --- a/test/simulation/tests-integration.go +++ b/test/simulation/tests-integration.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "github.com/ExchangeUnion/xud-simulation/connexttest" + // "github.com/ExchangeUnion/xud-simulation/connexttest" "time" "github.com/ExchangeUnion/xud-simulation/xudrpc" @@ -18,10 +18,6 @@ var integrationTestCases = []*testCase{ name: "order matching and swap", test: testOrderMatchingAndSwap, }, - { - name: "order matching and swap connext", - test: testOrderMatchingAndSwapConnext, - }, { name: "dust order discarded", test: testDustOrderDiscarded, @@ -244,15 +240,15 @@ func testInternalMatchAndInvalidation(net *xudtest.NetworkHarness, ht *harnessTe func testRuntimeAddPairActiveOrders(net *xudtest.NetworkHarness, ht *harnessTest) { // Remove previously-added pairs/currencies from both Alice and Bob. ht.act.removePair(net.Alice, "LTC/BTC") - ht.act.removePair(net.Alice, "BTC/ETH") + // ht.act.removePair(net.Alice, "BTC/ETH") ht.act.removeCurrency(net.Alice, "LTC") ht.act.removeCurrency(net.Alice, "BTC") - ht.act.removeCurrency(net.Alice, "ETH") + // ht.act.removeCurrency(net.Alice, "ETH") ht.act.removePair(net.Bob, "LTC/BTC") - ht.act.removePair(net.Bob, "BTC/ETH") + // ht.act.removePair(net.Bob, "BTC/ETH") ht.act.removeCurrency(net.Bob, "LTC") ht.act.removeCurrency(net.Bob, "BTC") - ht.act.removeCurrency(net.Bob, "ETH") + // ht.act.removeCurrency(net.Bob, "ETH") // Connect Alice to Bob. ht.act.connect(net.Alice, net.Bob) @@ -261,9 +257,10 @@ func testRuntimeAddPairActiveOrders(net *xudtest.NetworkHarness, ht *harnessTest // Re-add the pairs/currencies to Alice after peer connection was already established. ht.act.addCurrency(net.Alice, "BTC", xudrpc.Currency_LND, "", 8) ht.act.addCurrency(net.Alice, "LTC", xudrpc.Currency_LND, "", 8) - ht.act.addCurrency(net.Alice, "ETH", xudrpc.Currency_CONNEXT, connexttest.ETHTokenAddress, 18) + // TODO(karl): enable connext V2 simulation tests + // ht.act.addCurrency(net.Alice, "ETH", xudrpc.Currency_CONNEXT, connexttest.ETHTokenAddress, 18) ht.act.addPair(net.Alice, "LTC", "BTC") - ht.act.addPair(net.Alice, "BTC", "ETH") + // ht.act.addPair(net.Alice, "BTC", "ETH") // Place LTC/BTC order on Alice. req := &xudrpc.PlaceOrderRequest{ @@ -296,33 +293,35 @@ func testRuntimeAddPairActiveOrders(net *xudtest.NetworkHarness, ht *harnessTest ht.act.removeOrderAndInvalidate(net.Alice, net.Bob, res.RemainingOrder) // Place BTC/ETH order on Alice. - req = &xudrpc.PlaceOrderRequest{ - OrderId: "maker_order_id", - Price: 40, - Quantity: 100, - PairId: "BTC/ETH", - Side: xudrpc.OrderSide_BUY, - } - res, err = net.Alice.Client.PlaceOrderSync(ht.ctx, req) - ht.assert.NoError(err) - ht.assert.Len(res.InternalMatches, 0) - ht.assert.Len(res.SwapSuccesses, 0) - ht.assert.Len(res.SwapFailures, 0) - ht.assert.NotNil(res.RemainingOrder) - - // Bob should receive the order once his BTC/ETH pair is re-added. - bobOrdersChan = subscribeOrders(ht.ctx, net.Bob) - ht.act.addCurrency(net.Bob, "ETH", xudrpc.Currency_CONNEXT, connexttest.ETHTokenAddress, 18) - ht.act.addPair(net.Bob, "BTC", "ETH") - - e = <-bobOrdersChan - ht.assert.NoError(e.err) - ht.assert.NotNil(e.orderUpdate) - peerOrder = e.orderUpdate.GetOrder() - ht.assert.Equal(peerOrder.Id, res.RemainingOrder.Id) - ht.assert.Equal(peerOrder.PairId, req.PairId) - ht.assert.Equal(peerOrder.NodeIdentifier.NodePubKey, net.Alice.PubKey()) - ht.act.removeOrderAndInvalidate(net.Alice, net.Bob, res.RemainingOrder) + /* + req = &xudrpc.PlaceOrderRequest{ + OrderId: "maker_order_id", + Price: 40, + Quantity: 100, + PairId: "BTC/ETH", + Side: xudrpc.OrderSide_BUY, + } + res, err = net.Alice.Client.PlaceOrderSync(ht.ctx, req) + ht.assert.NoError(err) + ht.assert.Len(res.InternalMatches, 0) + ht.assert.Len(res.SwapSuccesses, 0) + ht.assert.Len(res.SwapFailures, 0) + ht.assert.NotNil(res.RemainingOrder) + + // Bob should receive the order once his BTC/ETH pair is re-added. + bobOrdersChan = subscribeOrders(ht.ctx, net.Bob) + ht.act.addCurrency(net.Bob, "ETH", xudrpc.Currency_CONNEXT, connexttest.ETHTokenAddress, 18) + ht.act.addPair(net.Bob, "BTC", "ETH") + + e = <-bobOrdersChan + ht.assert.NoError(e.err) + ht.assert.NotNil(e.orderUpdate) + peerOrder = e.orderUpdate.GetOrder() + ht.assert.Equal(peerOrder.Id, res.RemainingOrder.Id) + ht.assert.Equal(peerOrder.PairId, req.PairId) + ht.assert.Equal(peerOrder.NodeIdentifier.NodePubKey, net.Alice.PubKey()) + ht.act.removeOrderAndInvalidate(net.Alice, net.Bob, res.RemainingOrder) + */ // Cleanup. ht.act.disconnect(net.Alice, net.Bob) @@ -491,75 +490,6 @@ func testOrderReplacement(net *xudtest.NetworkHarness, ht *harnessTest) { ht.act.disconnect(net.Alice, net.Bob) } -func testOrderMatchingAndSwapConnext(net *xudtest.NetworkHarness, ht *harnessTest) { - // Connect Alice to Bob. - ht.act.connect(net.Alice, net.Bob) - ht.act.verifyConnectivity(net.Alice, net.Bob) - - ht.act.FundETH(net, net.Alice) - - preChanAliceBal, err := net.Alice.Client.GetBalance(ht.ctx, &xudrpc.GetBalanceRequest{Currency: "ETH"}) - ht.assert.NoError(err) - preChanAliceEthBal := preChanAliceBal.Balances["ETH"] - - // Open channel from Alice. - err = openETHChannel(ht.ctx, net.Alice, 40000, 0) - ht.assert.NoError(err) - // wait for 1 block for the deposit transaction to confirm - time.Sleep(15 * time.Second) - - // Verify Alice ETH balance. - chanFeesThreshold := uint64(2100) - preSwapAliceBal, err := net.Alice.Client.GetBalance(ht.ctx, &xudrpc.GetBalanceRequest{Currency: "ETH"}) - preSwapAliceEthBal := preSwapAliceBal.Balances["ETH"] - ht.assert.True(preChanAliceEthBal.TotalBalance-preSwapAliceEthBal.TotalBalance <= chanFeesThreshold) - ht.assert.Equal(preSwapAliceEthBal.TotalBalance-preSwapAliceEthBal.ChannelBalance, preSwapAliceEthBal.WalletBalance) - ht.assert.Equal(uint64(40000), preSwapAliceEthBal.ChannelBalance) - - // wait for 1 block for node to collateralize ETH channel - time.Sleep(15 * time.Second) - - // Place an order on Alice. - req := &xudrpc.PlaceOrderRequest{ - OrderId: "maker_order_id", - Price: 40, - Quantity: 100, - PairId: "BTC/ETH", - Side: xudrpc.OrderSide_BUY, - } - ht.act.placeOrderAndBroadcast(net.Alice, net.Bob, req) - - // Place a matching order on Bob. - req = &xudrpc.PlaceOrderRequest{ - OrderId: "taker_order_id", - Price: req.Price, - Quantity: req.Quantity, - PairId: req.PairId, - Side: xudrpc.OrderSide_SELL, - } - ht.act.placeOrderAndSwap(net.Bob, net.Alice, req) - - time.Sleep(5 * time.Second) - - // Verify Alice ETH balance. - amt := uint64(req.Price * float64(req.Quantity)) - aliceBal, err := net.Alice.Client.GetBalance(ht.ctx, &xudrpc.GetBalanceRequest{Currency: "ETH"}) - aliceEthBal := aliceBal.Balances["ETH"] - ht.assert.Equal(preSwapAliceEthBal.TotalBalance-amt, aliceEthBal.TotalBalance) - ht.assert.Equal(aliceEthBal.TotalBalance-aliceEthBal.ChannelBalance, aliceEthBal.WalletBalance) - ht.assert.Equal(preSwapAliceEthBal.ChannelBalance-amt, aliceEthBal.ChannelBalance) - - // Verify Bob ETH balance. - bobBalance, err := net.Bob.Client.GetBalance(ht.ctx, &xudrpc.GetBalanceRequest{Currency: "ETH"}) - bobEthBalance := bobBalance.Balances["ETH"] - ht.assert.Equal(amt, bobEthBalance.TotalBalance) - ht.assert.Equal(uint64(0), bobEthBalance.WalletBalance) - ht.assert.Equal(amt, bobEthBalance.ChannelBalance) - - // Cleanup. - ht.act.disconnect(net.Alice, net.Bob) -} - func testMultiHopSwap(net *xudtest.NetworkHarness, ht *harnessTest) { // Connect Alice to Dave. ht.act.connect(net.Alice, net.Dave) diff --git a/test/simulation/xud_test.go b/test/simulation/xud_test.go index 49947c2bd..9648e8710 100644 --- a/test/simulation/xud_test.go +++ b/test/simulation/xud_test.go @@ -3,11 +3,11 @@ package main import ( "context" "fmt" - "github.com/ExchangeUnion/xud-simulation/connexttest" - "github.com/ethereum/go-ethereum/ethclient" + // "github.com/ExchangeUnion/xud-simulation/connexttest" + // "github.com/ethereum/go-ethereum/ethclient" "github.com/stretchr/testify/require" "log" - "net/http" + // "net/http" "os" "strings" "testing" @@ -275,6 +275,7 @@ func TestSecurityUnsettledChannels(t *testing.T) { } } +/* func verifyEthProviderReachability() error { client, err := ethclient.Dial(connexttest.EthProviderURL) if err != nil { @@ -297,14 +298,17 @@ func verifyConnextNodeReachability() error { return nil } +*/ func launchNetwork(noBalanceChecks bool) (*xudtest.NetworkHarness, func()) { - if err := verifyEthProviderReachability(); err != nil { - log.Fatalf("EthProvider reachability failure: %v", err) - } - if err := verifyConnextNodeReachability(); err != nil { - log.Fatalf("Connext node reachability failure: %v", err) - } + /* + if err := verifyEthProviderReachability(); err != nil { + log.Fatalf("EthProvider reachability failure: %v", err) + } + if err := verifyConnextNodeReachability(); err != nil { + log.Fatalf("Connext node reachability failure: %v", err) + } + */ // Create XUD network instance without launching it. log.Printf("xud: creating network") @@ -439,34 +443,36 @@ func launchNetwork(noBalanceChecks bool) (*xudtest.NetworkHarness, func()) { log.Fatalf("lnd-btc: unable to set up test network: %v", err) } - connextNetworkHarness := connexttest.NewNetworkHarness() - go func() { - for { - select { - case err, more := <-connextNetworkHarness.ProcessErrors(): - if !more { - return + /* + connextNetworkHarness := connexttest.NewNetworkHarness() + go func() { + for { + select { + case err, more := <-connextNetworkHarness.ProcessErrors(): + if !more { + return + } + if strings.Contains(err.Err.Error(), "signal: terminated") { + continue + } + + log.Printf("connext: finished with error (stderr):\n%v", err) } - if strings.Contains(err.Err.Error(), "signal: terminated") { - continue - } - - log.Printf("connext: finished with error (stderr):\n%v", err) } + }() + log.Printf("connext: launching network...") + if err := connextNetworkHarness.SetUp(); err != nil { + log.Fatalf("connext: unable to set up test network: %v", err) } - }() - log.Printf("connext: launching network...") - if err := connextNetworkHarness.SetUp(); err != nil { - log.Fatalf("connext: unable to set up test network: %v", err) - } - if err := connextNetworkHarness.Start(); err != nil { - log.Fatalf("connext: unable to start test network: %v", err) - } + if err := connextNetworkHarness.Start(); err != nil { + log.Fatalf("connext: unable to start test network: %v", err) + } + */ // Launch XUD network. xudHarness.SetLnd(lndBtcNetworkHarness, "BTC") xudHarness.SetLnd(lndLtcNetworkHarness, "LTC") - xudHarness.SetConnext(connextNetworkHarness) + // xudHarness.SetConnext(connextNetworkHarness) log.Printf("xud: launching network...") if err := xudHarness.Start(); err != nil { @@ -495,10 +501,12 @@ func launchNetwork(noBalanceChecks bool) (*xudtest.NetworkHarness, func()) { } log.Printf("ltcd: harness teared down") - if err := connextNetworkHarness.TearDownAll(); err != nil { - log.Printf("connext: cannot tear down network harness: %v", err) - } - log.Printf("connext: network harness teared down") + /* + if err := connextNetworkHarness.TearDownAll(); err != nil { + log.Printf("connext: cannot tear down network harness: %v", err) + } + log.Printf("connext: network harness teared down") + */ if err := xudHarness.TearDownAll(cfg.XudKill, cfg.XudCleanup); err != nil { log.Fatalf("cannot tear down xud network harness: %v", err) diff --git a/test/simulation/xudtest/harness.go b/test/simulation/xudtest/harness.go index 01f169c73..f1b7a4a5e 100644 --- a/test/simulation/xudtest/harness.go +++ b/test/simulation/xudtest/harness.go @@ -2,8 +2,8 @@ package xudtest import ( "context" - "fmt" - "github.com/ExchangeUnion/xud-simulation/connexttest" + // "fmt" + // "github.com/ExchangeUnion/xud-simulation/connexttest" "sync" "time" @@ -25,9 +25,9 @@ type NetworkHarness struct { Carol *HarnessNode Dave *HarnessNode - LndBtcNetwork *lntest.NetworkHarness - LndLtcNetwork *lntest.NetworkHarness - ConnextNetwork *connexttest.NetworkHarness + LndBtcNetwork *lntest.NetworkHarness + LndLtcNetwork *lntest.NetworkHarness + // ConnextNetwork *connexttest.NetworkHarness errorChan chan *XudError @@ -50,6 +50,7 @@ type CtxSetter interface { SetCtx(ctx context.Context, cancel context.CancelFunc) } +/* func (n *NetworkHarness) newConnextClient(ctx context.Context, node *HarnessNode, envVars *[]string) (*connexttest.HarnessClient, error) { if err := n.ConnextNetwork.TearDown(node.ConnextClient.ID); err != nil { return nil, err @@ -72,14 +73,17 @@ func (n *NetworkHarness) newConnextClient(ctx context.Context, node *HarnessNode return client, nil } +*/ func (n *NetworkHarness) SetCustomXud(ctx context.Context, ctxSetter CtxSetter, node *HarnessNode, envVars []string) (*HarnessNode, error) { t := time.Now() - connextClient, err := n.newConnextClient(ctx, node, &envVars) - if err != nil { - return nil, err - } + /* + connextClient, err := n.newConnextClient(ctx, node, &envVars) + if err != nil { + return nil, err + } + */ if err := node.shutdown(true, true); err != nil { return nil, err @@ -93,7 +97,7 @@ func (n *NetworkHarness) SetCustomXud(ctx context.Context, ctxSetter CtxSetter, customNode.SetEnvVars(envVars) customNode.SetLnd(node.LndBtcNode, "BTC") customNode.SetLnd(node.LndLtcNode, "LTC") - customNode.SetConnextClient(connextClient) + // customNode.SetConnextClient(connextClient) if err := customNode.Start(n.errorChan); err != nil { return nil, err @@ -193,6 +197,7 @@ func (n *NetworkHarness) SetLnd(ln *lntest.NetworkHarness, chain string) { n.Dave.SetLnd(ln.Dave, chain) } +/* func (n *NetworkHarness) SetConnext(net *connexttest.NetworkHarness) { n.ConnextNetwork = net n.Alice.SetConnextClient(net.Alice) @@ -200,6 +205,7 @@ func (n *NetworkHarness) SetConnext(net *connexttest.NetworkHarness) { n.Carol.SetConnextClient(net.Carol) n.Dave.SetConnextClient(net.Dave) } +*/ // ProcessErrors returns a channel used for reporting any fatal process errors. // If any of the active nodes within the harness' test network incur a fatal diff --git a/test/simulation/xudtest/node.go b/test/simulation/xudtest/node.go index ca6921f5d..aff97d607 100644 --- a/test/simulation/xudtest/node.go +++ b/test/simulation/xudtest/node.go @@ -13,7 +13,7 @@ import ( "sync/atomic" "time" - "github.com/ExchangeUnion/xud-simulation/connexttest" + // "github.com/ExchangeUnion/xud-simulation/connexttest" "context" @@ -91,23 +91,26 @@ func (cfg nodeConfig) genArgs() []string { args = append(args, fmt.Sprintf("--lnd.LTC.port=%v", cfg.LndLtcPort)) args = append(args, fmt.Sprintf("--lnd.LTC.certpath=%v", cfg.LndLtcCertPath)) args = append(args, fmt.Sprintf("--lnd.LTC.macaroonpath=%v", cfg.LndLtcMacPath)) + args = append(args, "--connext.disable") + + /* + if !cfg.RaidenDisable { + args = append(args, fmt.Sprintf("--raiden.host=%v", cfg.RaidenHost)) + args = append(args, fmt.Sprintf("--raiden.port=%v", cfg.RaidenPort)) + } else { + args = append(args, "--raiden.disable") + } - if !cfg.RaidenDisable { - args = append(args, fmt.Sprintf("--raiden.host=%v", cfg.RaidenHost)) - args = append(args, fmt.Sprintf("--raiden.port=%v", cfg.RaidenPort)) - } else { - args = append(args, "--raiden.disable") - } - - if !cfg.ConnextDisable { - args = append(args, fmt.Sprintf("--connext.host=%v", cfg.ConnextHost)) - args = append(args, fmt.Sprintf("--connext.port=%v", cfg.ConnextPort)) - args = append(args, "--connext.webhookhost=127.0.0.1") - args = append(args, fmt.Sprintf("--connext.webhookport=%v", cfg.HTTPPort)) + if !cfg.ConnextDisable { + args = append(args, fmt.Sprintf("--connext.host=%v", cfg.ConnextHost)) + args = append(args, fmt.Sprintf("--connext.port=%v", cfg.ConnextPort)) + args = append(args, "--connext.webhookhost=127.0.0.1") + args = append(args, fmt.Sprintf("--connext.webhookport=%v", cfg.HTTPPort)) - } else { - args = append(args, "--connext.disable") - } + } else { + args = append(args, "--connext.disable") + } + */ return args } @@ -124,9 +127,9 @@ type HarnessNode struct { ID int pubKey string - LndBtcNode *lntest.HarnessNode - LndLtcNode *lntest.HarnessNode - ConnextClient *connexttest.HarnessClient + LndBtcNode *lntest.HarnessNode + LndLtcNode *lntest.HarnessNode + // ConnextClient *connexttest.HarnessClient // processExit is a channel that's closed once it's detected that the // process this instance of HarnessNode is bound to has exited. @@ -209,11 +212,13 @@ func (hn *HarnessNode) SetLnd(lndNode *lntest.HarnessNode, chain string) { } } +/* func (hn *HarnessNode) SetConnextClient(client *connexttest.HarnessClient) { hn.Cfg.ConnextHost = "0.0.0.0" hn.Cfg.ConnextPort = client.Cfg.Port hn.ConnextClient = client } +*/ func (hn *HarnessNode) SetEnvVars(envVars []string) { hn.EnvVars = envVars