Skip to content

Commit

Permalink
chore: remove debugAPI option in testserver
Browse files Browse the repository at this point in the history
  • Loading branch information
acha-bill committed May 29, 2024
1 parent ff48d18 commit b2ad00b
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 133 deletions.
2 changes: 0 additions & 2 deletions pkg/api/accounting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func TestAccountingInfo(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithPeerAccountingFunc(accountingFunc)},
})

Expand Down Expand Up @@ -112,7 +111,6 @@ func TestAccountingInfoError(t *testing.T) {
return nil, wantErr
}
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithPeerAccountingFunc(accountingFunc)},
})

Expand Down
1 change: 0 additions & 1 deletion pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ type testServerOptions struct {
Steward steward.Interface
WsHeaders http.Header
Authenticator auth.Authenticator
DebugAPI bool
Restricted bool
DirectUpload bool
Probe *api.Probe
Expand Down
14 changes: 2 additions & 12 deletions pkg/api/balances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func TestBalances(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithCompensatedBalancesFunc(compensatedBalancesFunc)},
})

Expand Down Expand Up @@ -72,7 +71,6 @@ func TestBalancesError(t *testing.T) {
return nil, wantErr
}
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithCompensatedBalancesFunc(compensatedBalancesFunc)},
})

Expand All @@ -92,7 +90,6 @@ func TestBalancesPeers(t *testing.T) {
return big.NewInt(100000000000000000), nil
}
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithCompensatedBalanceFunc(compensatedBalanceFunc)},
})

Expand All @@ -113,7 +110,6 @@ func TestBalancesPeersError(t *testing.T) {
return nil, wantErr
}
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithCompensatedBalanceFunc(compensatedBalanceFunc)},
})

Expand All @@ -133,7 +129,6 @@ func TestBalancesPeersNoBalance(t *testing.T) {
return nil, accounting.ErrPeerNoBalance
}
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithCompensatedBalanceFunc(compensatedBalanceFunc)},
})

Expand Down Expand Up @@ -186,7 +181,6 @@ func TestConsumedBalances(t *testing.T) {
return ret, err
}
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithBalancesFunc(balancesFunc)},
})

Expand Down Expand Up @@ -227,7 +221,6 @@ func TestConsumedError(t *testing.T) {
return nil, wantErr
}
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithBalancesFunc(balancesFunc)},
})

Expand All @@ -247,7 +240,6 @@ func TestConsumedPeers(t *testing.T) {
return big.NewInt(1000000000000000000), nil
}
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithBalanceFunc(balanceFunc)},
})

Expand All @@ -268,7 +260,6 @@ func TestConsumedPeersError(t *testing.T) {
return nil, wantErr
}
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithBalanceFunc(balanceFunc)},
})

Expand All @@ -288,7 +279,6 @@ func TestConsumedPeersNoBalance(t *testing.T) {
return nil, accounting.ErrPeerNoBalance
}
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
AccountingOpts: []mock.Option{mock.WithBalanceFunc(balanceFunc)},
})

Expand All @@ -303,7 +293,7 @@ func TestConsumedPeersNoBalance(t *testing.T) {
func Test_peerBalanceHandler_invalidInputs(t *testing.T) {
t.Parallel()

client, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true})
client, _, _, _ := newTestServer(t, testServerOptions{})

tests := []struct {
name string
Expand Down Expand Up @@ -352,7 +342,7 @@ func Test_peerBalanceHandler_invalidInputs(t *testing.T) {
func Test_compensatedPeerBalanceHandler_invalidInputs(t *testing.T) {
t.Parallel()

client, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true})
client, _, _, _ := newTestServer(t, testServerOptions{})

tests := []struct {
name string
Expand Down
17 changes: 1 addition & 16 deletions pkg/api/chequebook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestChequebookBalance(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
ChequebookOpts: []mock.Option{
mock.WithChequebookBalanceFunc(chequebookBalanceFunc),
mock.WithChequebookAvailableBalanceFunc(chequebookAvailableBalanceFunc),
Expand Down Expand Up @@ -71,7 +70,6 @@ func TestChequebookBalanceError(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
ChequebookOpts: []mock.Option{mock.WithChequebookBalanceFunc(chequebookBalanceFunc)},
})

Expand All @@ -95,7 +93,6 @@ func TestChequebookAvailableBalanceError(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
ChequebookOpts: []mock.Option{
mock.WithChequebookBalanceFunc(chequebookBalanceFunc),
mock.WithChequebookAvailableBalanceFunc(chequebookAvailableBalanceFunc),
Expand All @@ -118,7 +115,6 @@ func TestChequebookAddress(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
ChequebookOpts: []mock.Option{mock.WithChequebookAddressFunc(chequebookAddressFunc)},
})

Expand Down Expand Up @@ -154,7 +150,6 @@ func TestChequebookWithdraw(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
ChequebookOpts: []mock.Option{mock.WithChequebookWithdrawFunc(chequebookWithdrawFunc)},
})

Expand Down Expand Up @@ -184,7 +179,6 @@ func TestChequebookWithdraw(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
ChequebookOpts: []mock.Option{mock.WithChequebookWithdrawFunc(chequebookWithdrawFunc)},
})

Expand Down Expand Up @@ -218,7 +212,6 @@ func TestChequebookDeposit(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
ChequebookOpts: []mock.Option{mock.WithChequebookDepositFunc(chequebookDepositFunc)},
})

Expand Down Expand Up @@ -249,7 +242,6 @@ func TestChequebookDeposit(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
ChequebookOpts: []mock.Option{mock.WithChequebookDepositFunc(chequebookDepositFunc)},
})

Expand Down Expand Up @@ -358,7 +350,6 @@ func TestChequebookLastCheques(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
SwapOpts: []swapmock.Option{swapmock.WithLastReceivedChequesFunc(lastReceivedChequesFunc), swapmock.WithLastSentChequesFunc(lastSentChequesFunc)},
})

Expand Down Expand Up @@ -472,7 +463,6 @@ func TestChequebookLastChequesPeer(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
SwapOpts: []swapmock.Option{swapmock.WithLastReceivedChequeFunc(lastReceivedChequeFunc), swapmock.WithLastSentChequeFunc(lastSentChequeFunc)},
})

Expand Down Expand Up @@ -512,7 +502,6 @@ func TestChequebookCashout(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
SwapOpts: []swapmock.Option{swapmock.WithCashChequeFunc(cashChequeFunc)},
})

Expand Down Expand Up @@ -543,7 +532,6 @@ func TestChequebookCashout_CustomGas(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
SwapOpts: []swapmock.Option{swapmock.WithCashChequeFunc(cashChequeFunc)},
})

Expand Down Expand Up @@ -619,7 +607,6 @@ func TestChequebookCashoutStatus(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
SwapOpts: []swapmock.Option{swapmock.WithCashoutStatusFunc(cashoutStatusFunc)},
})

Expand Down Expand Up @@ -667,7 +654,6 @@ func TestChequebookCashoutStatus(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
SwapOpts: []swapmock.Option{swapmock.WithCashoutStatusFunc(cashoutStatusFunc)},
})

Expand Down Expand Up @@ -706,7 +692,6 @@ func TestChequebookCashoutStatus(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
SwapOpts: []swapmock.Option{swapmock.WithCashoutStatusFunc(cashoutStatusFunc)},
})

Expand All @@ -733,7 +718,7 @@ func TestChequebookCashoutStatus(t *testing.T) {
func Test_chequebookLastPeerHandler_invalidInputs(t *testing.T) {
t.Parallel()

client, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true})
client, _, _, _ := newTestServer(t, testServerOptions{})

tests := []struct {
name string
Expand Down
3 changes: 1 addition & 2 deletions pkg/api/debugstorage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ func TestDebugStorage(t *testing.T) {
}

ts, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
Storer: mockstorer.NewWithDebugInfo(want),
Storer: mockstorer.NewWithDebugInfo(want),
})

jsonhttptest.Request(t, ts, http.MethodGet, "/debugstore", http.StatusOK,
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestGetLoggers(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}

client, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true})
client, _, _, _ := newTestServer(t, testServerOptions{})
jsonhttptest.Request(t, client, http.MethodGet, "/loggers", http.StatusOK,
jsonhttptest.WithUnmarshalJSONResponse(&have),
)
Expand All @@ -88,7 +88,7 @@ func TestSetLoggerVerbosity(t *testing.T) {
api.ReplaceLogSetVerbosityByExp(fn)
}(api.LogSetVerbosityByExp)

client, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true})
client, _, _, _ := newTestServer(t, testServerOptions{})

type data struct {
exp string
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestSetLoggerVerbosity(t *testing.T) {
func Test_loggerGetHandler_invalidInputs(t *testing.T) {
t.Parallel()

client, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true})
client, _, _, _ := newTestServer(t, testServerOptions{})

tests := []struct {
name string
Expand Down Expand Up @@ -192,7 +192,7 @@ func Test_loggerGetHandler_invalidInputs(t *testing.T) {
func Test_loggerSetVerbosityHandler_invalidInputs(t *testing.T) {
t.Parallel()

client, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true})
client, _, _, _ := newTestServer(t, testServerOptions{})

tests := []struct {
name string
Expand Down
2 changes: 0 additions & 2 deletions pkg/api/p2p_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestAddresses(t *testing.T) {
ethereumAddress := common.HexToAddress("abcd")

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
PublicKey: privateKey.PublicKey,
PSSPublicKey: pssPrivateKey.PublicKey,
Overlay: overlay,
Expand Down Expand Up @@ -79,7 +78,6 @@ func TestAddresses_error(t *testing.T) {
testErr := errors.New("test error")

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
P2P: mock.New(mock.WithAddressesFunc(func() ([]multiaddr.Multiaddr, error) {
return nil, testErr
})),
Expand Down
10 changes: 2 additions & 8 deletions pkg/api/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func TestConnect(t *testing.T) {
}

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
P2P: mock.New(mock.WithConnectFunc(func(ctx context.Context, addr ma.Multiaddr) (*bzz.Address, error) {
if addr.String() == errorUnderlay {
return nil, testErr
Expand Down Expand Up @@ -82,7 +81,6 @@ func TestConnect(t *testing.T) {
t.Run("error - add peer", func(t *testing.T) {
t.Parallel()
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
P2P: mock.New(mock.WithConnectFunc(func(ctx context.Context, addr ma.Multiaddr) (*bzz.Address, error) {
if addr.String() == errorUnderlay {
return nil, testErr
Expand All @@ -109,7 +107,6 @@ func TestDisconnect(t *testing.T) {
testErr := errors.New("test error")

testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
P2P: mock.New(mock.WithDisconnectFunc(func(addr swarm.Address, reason string) error {
if reason != "user requested disconnect" {
return testErr
Expand Down Expand Up @@ -166,7 +163,6 @@ func TestPeer(t *testing.T) {

overlay := swarm.MustParseHexAddress("ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c")
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
P2P: mock.New(mock.WithPeersFunc(func() []p2p.Peer {
return []p2p.Peer{{Address: overlay}}
})),
Expand All @@ -188,7 +184,6 @@ func TestBlocklistedPeers(t *testing.T) {

overlay := swarm.MustParseHexAddress("ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c")
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
P2P: mock.New(mock.WithBlocklistedPeersFunc(func() ([]p2p.BlockListedPeer, error) {
return []p2p.BlockListedPeer{{Peer: p2p.Peer{Address: overlay}}}, nil
})),
Expand All @@ -206,7 +201,6 @@ func TestBlocklistedPeersErr(t *testing.T) {

overlay := swarm.MustParseHexAddress("ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c")
testServer, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
P2P: mock.New(mock.WithBlocklistedPeersFunc(func() ([]p2p.BlockListedPeer, error) {
return []p2p.BlockListedPeer{{Peer: p2p.Peer{Address: overlay}}}, errors.New("some error")
})),
Expand All @@ -224,7 +218,7 @@ func TestBlocklistedPeersErr(t *testing.T) {
func Test_peerConnectHandler_invalidInputs(t *testing.T) {
t.Parallel()

client, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true})
client, _, _, _ := newTestServer(t, testServerOptions{})

tests := []struct {
name string
Expand Down Expand Up @@ -260,7 +254,7 @@ func Test_peerConnectHandler_invalidInputs(t *testing.T) {
func Test_peerDisconnectHandler_invalidInputs(t *testing.T) {
t.Parallel()

client, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true})
client, _, _, _ := newTestServer(t, testServerOptions{})

tests := []struct {
name string
Expand Down
3 changes: 1 addition & 2 deletions pkg/api/pingpong_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestPingpong(t *testing.T) {
})

ts, _, _, _ := newTestServer(t, testServerOptions{
DebugAPI: true,
Pingpong: pingpongService,
})

Expand Down Expand Up @@ -79,7 +78,7 @@ func TestPingpong(t *testing.T) {
func Test_pingpongHandler_invalidInputs(t *testing.T) {
t.Parallel()

client, _, _, _ := newTestServer(t, testServerOptions{DebugAPI: true})
client, _, _, _ := newTestServer(t, testServerOptions{})

tests := []struct {
name string
Expand Down
Loading

0 comments on commit b2ad00b

Please sign in to comment.