From b93140cd3c2fb0cd889293df93bf6abbaa7564d5 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Thu, 9 Apr 2020 20:20:47 +0200 Subject: [PATCH] switch: remove unused code --- htlcswitch/circuit_test.go | 16 ++++++++-------- htlcswitch/decayedlog.go | 3 --- htlcswitch/decayedlog_test.go | 2 +- htlcswitch/link_test.go | 6 +++--- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/htlcswitch/circuit_test.go b/htlcswitch/circuit_test.go index 3dc0f470..1b5d59e8 100644 --- a/htlcswitch/circuit_test.go +++ b/htlcswitch/circuit_test.go @@ -535,7 +535,7 @@ func TestCircuitMapPersistence(t *testing.T) { // Check that the circuit map is empty, even after restarting. assertNumCircuitsWithHash(t, circuitMap, hash3, 0) - cfg, circuitMap = restartCircuitMap(t, cfg) + _, circuitMap = restartCircuitMap(t, cfg) assertNumCircuitsWithHash(t, circuitMap, hash3, 0) } @@ -717,7 +717,7 @@ func TestCircuitMapCommitCircuits(t *testing.T) { // to be loaded from disk. Since the keystone was never set, subsequent // attempts to commit the circuit should cause the circuit map to // indicate that the HTLC should be failed back. - cfg, circuitMap = restartCircuitMap(t, cfg) + _, circuitMap = restartCircuitMap(t, cfg) actions, err = circuitMap.CommitCircuits(circuit) if err != nil { @@ -837,7 +837,7 @@ func TestCircuitMapOpenCircuits(t *testing.T) { // // NOTE: The channel db doesn't have any channel data, so no keystones // will be trimmed. - cfg, circuitMap = restartCircuitMap(t, cfg) + _, circuitMap = restartCircuitMap(t, cfg) // Check that we can still query for the open circuit. circuit2 = circuitMap.LookupOpenCircuit(keystone.OutKey) @@ -1081,7 +1081,7 @@ func TestCircuitMapTrimOpenCircuits(t *testing.T) { // Restart the circuit map one last time to make sure the changes are // persisted. - cfg, circuitMap = restartCircuitMap(t, cfg) + _, circuitMap = restartCircuitMap(t, cfg) assertCircuitsOpenedPostRestart( t, @@ -1179,7 +1179,7 @@ func TestCircuitMapCloseOpenCircuits(t *testing.T) { // // NOTE: The channel db doesn't have any channel data, so no keystones // will be trimmed. - cfg, circuitMap = restartCircuitMap(t, cfg) + _, circuitMap = restartCircuitMap(t, cfg) // Close the open circuit for the first time, which should succeed. _, err = circuitMap.FailCircuit(circuit.Incoming) @@ -1237,7 +1237,7 @@ func TestCircuitMapCloseUnopenedCircuit(t *testing.T) { // Now, restart the circuit map, which will result in the circuit being // reopened, since no attempt to delete the circuit was made. - cfg, circuitMap = restartCircuitMap(t, cfg) + _, circuitMap = restartCircuitMap(t, cfg) // Close the open circuit for the first time, which should succeed. _, err = circuitMap.FailCircuit(circuit.Incoming) @@ -1301,7 +1301,7 @@ func TestCircuitMapDeleteUnopenedCircuit(t *testing.T) { // Now, restart the circuit map, and check that the deletion survived // the restart. - cfg, circuitMap = restartCircuitMap(t, cfg) + _, circuitMap = restartCircuitMap(t, cfg) circuit2 = circuitMap.LookupCircuit(circuit.Incoming) if circuit2 != nil { @@ -1374,7 +1374,7 @@ func TestCircuitMapDeleteOpenCircuit(t *testing.T) { // Now, restart the circuit map, and check that the deletion survived // the restart. - cfg, circuitMap = restartCircuitMap(t, cfg) + _, circuitMap = restartCircuitMap(t, cfg) circuit2 = circuitMap.LookupOpenCircuit(keystone.OutKey) if circuit2 != nil { diff --git a/htlcswitch/decayedlog.go b/htlcswitch/decayedlog.go index 3a60e112..42c845e1 100644 --- a/htlcswitch/decayedlog.go +++ b/htlcswitch/decayedlog.go @@ -17,9 +17,6 @@ const ( // defaultDbDirectory is the default directory where our decayed log // will store our (sharedHash, CLTV) key-value pairs. defaultDbDirectory = "sharedhashes" - - // dbPermissions sets the database permissions to user write-and-readable. - dbPermissions = 0600 ) var ( diff --git a/htlcswitch/decayedlog_test.go b/htlcswitch/decayedlog_test.go index 6cf97c50..7ebe1f10 100644 --- a/htlcswitch/decayedlog_test.go +++ b/htlcswitch/decayedlog_test.go @@ -122,7 +122,7 @@ func TestDecayedLogGarbageCollector(t *testing.T) { time.Sleep(500 * time.Millisecond) // Assert that hashedSecret is not in the sharedHashBucket - val, err = d.Get(hashedSecret) + _, err = d.Get(hashedSecret) if err == nil { t.Fatalf("CLTV was not deleted") } diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index 935ccde3..bbe418c9 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -2040,7 +2040,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) { // Next, we'll add another HTLC initiated by the switch (of the same // amount as the prior one). - invoice, htlc, _, err = generatePayment(htlcAmt, htlcAmt, 5, mockBlob) + _, htlc, _, err = generatePayment(htlcAmt, htlcAmt, 5, mockBlob) if err != nil { t.Fatalf("unable to create payment: %v", err) } @@ -2143,7 +2143,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) { } htlc.ID = 0 - bobIndex, err = bobChannel.AddHTLC(htlc, nil) + _, err = bobChannel.AddHTLC(htlc, nil) if err != nil { t.Fatalf("unable to add htlc: %v", err) } @@ -2253,7 +2253,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) { // HTLC we add, hence it should have an ID of 1 (Alice's channel // link will set this automatically for her side). htlc.ID = 1 - bobIndex, err = bobChannel.AddHTLC(htlc, nil) + _, err = bobChannel.AddHTLC(htlc, nil) if err != nil { t.Fatalf("unable to add htlc: %v", err) }