htlcswitch: run all unit tests in parallel

This commit is contained in:
Olaoluwa Osuntokun 2017-06-17 00:41:42 +02:00
parent a43b5658bb
commit bb9bc9205a
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
3 changed files with 24 additions and 1 deletions

View File

@ -13,6 +13,8 @@ import (
// waiting queue, by executing methods in seprate goroutines which operates
// with the same data.
func TestWaitingQueueThreadSafety(t *testing.T) {
t.Parallel()
q := newWaitingQueue()
a := make([]btcutil.Amount, 1000)

View File

@ -30,6 +30,8 @@ var (
// TestSwitchForward checks the ability of htlc switch to forward add/settle
// requests.
func TestSwitchForward(t *testing.T) {
t.Parallel()
var packet *htlcPacket
alicePeer := newMockServer(t, "alice")
@ -106,6 +108,8 @@ func TestSwitchForward(t *testing.T) {
// TestSwitchCancel checks that if htlc was rejected we remove unused
// circuits.
func TestSwitchCancel(t *testing.T) {
t.Parallel()
var request *htlcPacket
alicePeer := newMockServer(t, "alice")
@ -180,6 +184,8 @@ func TestSwitchCancel(t *testing.T) {
// TestSwitchAddSamePayment tests that we send the payment with the same
// payment hash.
func TestSwitchAddSamePayment(t *testing.T) {
t.Parallel()
var request *htlcPacket
alicePeer := newMockServer(t, "alice")
@ -279,6 +285,8 @@ func TestSwitchAddSamePayment(t *testing.T) {
// TestSwitchSendPayment tests ability of htlc switch to respond to the
// users when response is came back from channel link.
func TestSwitchSendPayment(t *testing.T) {
t.Parallel()
alicePeer := newMockServer(t, "alice")
aliceChannelLink := newMockChannelLink(chanID1, aliceChanID, alicePeer)

View File

@ -315,7 +315,9 @@ type threeHopNetwork struct {
globalPolicy ForwardingPolicy
}
// generateHops...
// generateHops creates the per hop payload, the total amount to be sent, and
// also the time lock value needed to route a HTLC with the target amount over
// the specified path.
func generateHops(payAmt btcutil.Amount,
path ...*channelLink) (btcutil.Amount, uint32, []ForwardingInfo) {
@ -328,19 +330,27 @@ func generateHops(payAmt btcutil.Amount,
hops := make([]ForwardingInfo, len(path))
for i := len(path) - 1; i >= 0; i-- {
// If this is the last hop, then the next hop is the special
// "exit node". Otherwise, we look to the "prior" hop.
nextHop := exitHop
if i != len(path)-1 {
nextHop = path[i+1].channel.ShortChanID()
}
// If this is the last, hop, then the time lock will be their
// specified delta policy.
timeLock := lastHop.cfg.FwrdingPolicy.TimeLockDelta
totalTimelock += timeLock
// Otherwise, the outgoing time lock should be the incoming
// timelock minus their specified delta.
if i != len(path)-1 {
delta := path[i].cfg.FwrdingPolicy.TimeLockDelta
timeLock = totalTimelock - delta
}
// Finally, we'll need to calculate the amount to forward. For
// the last hop, it's just the payment amount.
amount := payAmt
if i != len(path)-1 {
prevHop := hops[i+1]
@ -349,6 +359,9 @@ func generateHops(payAmt btcutil.Amount,
fee := ExpectedFee(path[i].cfg.FwrdingPolicy, prevAmount)
runningAmt += fee
// If the this the first hop, then we don't need to
// apply any fee, otherwise, the amount to forward
// needs to take into account the fees.
if i == 0 {
amount = prevAmount
} else {