Skip to content

Commit

Permalink
refactor: revert non ACT related files
Browse files Browse the repository at this point in the history
  • Loading branch information
kopi-solarpunk committed May 13, 2024
1 parent 2ec0977 commit 2098dc0
Show file tree
Hide file tree
Showing 31 changed files with 73 additions and 39 deletions.
1 change: 1 addition & 0 deletions pkg/api/accounting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func TestAccountingInfo(t *testing.T) {
if !reflect.DeepEqual(got, expected) {
t.Errorf("got accounting: %v, expected: %v", got, expected)
}

}

func TestAccountingInfoError(t *testing.T) {
Expand Down
8 changes: 5 additions & 3 deletions pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func newTestServer(t *testing.T, o testServerOptions) (*http.Client, *websocket.
erc20 := erc20mock.New(o.Erc20Opts...)
backend := backendmock.New(o.BackendOpts...)

extraOpts := api.ExtraOptions{
var extraOpts = api.ExtraOptions{
TopologyDriver: topologyDriver,
Accounting: acc,
Pseudosettle: recipient,
Expand Down Expand Up @@ -344,7 +344,7 @@ func TestParseName(t *testing.T) {
const bzzHash = "89c17d0d8018a19057314aa035e61c9d23c47581a61dd3a79a7839692c617e4d"
log := log.Noop

errInvalidNameOrAddress := errors.New("invalid name or bzz address")
var errInvalidNameOrAddress = errors.New("invalid name or bzz address")

testCases := []struct {
desc string
Expand Down Expand Up @@ -531,7 +531,9 @@ func TestPostageHeaderError(t *testing.T) {
func TestOptions(t *testing.T) {
t.Parallel()

client, _, _, _ := newTestServer(t, testServerOptions{})
var (
client, _, _, _ = newTestServer(t, testServerOptions{})
)
for _, tc := range []struct {
endpoint string
expectedMethods string // expectedMethods contains HTTP methods like GET, POST, HEAD, PATCH, DELETE, OPTIONS. These are in alphabetical sorted order
Expand Down
1 change: 1 addition & 0 deletions pkg/api/balances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ func TestConsumedBalances(t *testing.T) {
if !equalBalances(got, expected) {
t.Errorf("got balances: %v, expected: %v", got, expected)
}

}

func TestConsumedError(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/api/bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ func TestBytesInvalidStamp(t *testing.T) {
jsonhttptest.WithRequestBody(bytes.NewReader(content)),
)
})

}

func TestBytesUploadHandlerInvalidInputs(t *testing.T) {
Expand Down
9 changes: 5 additions & 4 deletions pkg/api/bzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import (
"strings"
"time"

"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
olog "github.com/opentracing/opentracing-go/log"

"github.com/ethereum/go-ethereum/common"
"github.com/ethersphere/bee/v2/pkg/feeds"
"github.com/ethersphere/bee/v2/pkg/file/joiner"
Expand All @@ -33,9 +37,6 @@ import (
"github.com/ethersphere/bee/v2/pkg/tracing"
"github.com/ethersphere/langos"
"github.com/gorilla/mux"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
olog "github.com/opentracing/opentracing-go/log"
)

// The size of buffer used for prefetching content with Langos when not using erasure coding
Expand Down Expand Up @@ -393,7 +394,7 @@ FETCH:
// go on normally.
if !feedDereferenced {
if l, err := s.manifestFeed(ctx, m); err == nil {
// we have a feed manifest here
//we have a feed manifest here
ch, cur, _, err := l.At(ctx, time.Now().Unix(), 0)
if err != nil {
logger.Debug("bzz download: feed lookup failed", "error", err)
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/bzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ func TestInvalidBzzParams(t *testing.T) {
jsonhttptest.WithRequestBody(tr),
jsonhttptest.WithRequestHeader(api.ContentTypeHeader, api.ContentTypeTar),
)

})

t.Run("batch exists", func(t *testing.T) {
Expand Down Expand Up @@ -961,6 +962,7 @@ func TestInvalidBzzParams(t *testing.T) {
jsonhttptest.WithRequestBody(tr),
jsonhttptest.WithRequestHeader(api.ContentTypeHeader, api.ContentTypeTar),
)

})

t.Run("batch not found", func(t *testing.T) {
Expand Down Expand Up @@ -1055,6 +1057,7 @@ func TestInvalidBzzParams(t *testing.T) {
address := "f30c0aa7e9e2a0ef4c9b1b750ebfeaeb7c7c24da700bb089da19a46e3677824b"
jsonhttptest.Request(t, client, http.MethodGet, fmt.Sprintf("/bzz/%s/", address), http.StatusNotFound)
})

}

// TestDirectUploadBzz tests that the direct upload endpoint give correct error message in dev mode
Expand Down
1 change: 1 addition & 0 deletions pkg/api/chequebook.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/ethersphere/bee/v2/pkg/postage/postagecontract"
"github.com/ethersphere/bee/v2/pkg/settlement/swap"
"github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook"

"github.com/ethersphere/bee/v2/pkg/swarm"
"github.com/gorilla/mux"
)
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/chequebook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook"
"github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook/mock"
swapmock "github.com/ethersphere/bee/v2/pkg/settlement/swap/mock"

"github.com/ethersphere/bee/v2/pkg/swarm"
)

Expand Down Expand Up @@ -426,6 +427,7 @@ func TestChequebookLastCheques(t *testing.T) {
if !LastChequesEqual(got, expected) {
t.Fatalf("Got: \n %+v \n\n Expected: \n %+v \n\n", got, expected)
}

}

func TestChequebookLastChequesPeer(t *testing.T) {
Expand All @@ -440,6 +442,7 @@ func TestChequebookLastChequesPeer(t *testing.T) {
sig := make([]byte, 65)

lastSentChequeFunc := func(swarm.Address) (*chequebook.SignedCheque, error) {

sig := make([]byte, 65)

lastSentCheque := &chequebook.SignedCheque{
Expand All @@ -455,6 +458,7 @@ func TestChequebookLastChequesPeer(t *testing.T) {
}

lastReceivedChequeFunc := func(swarm.Address) (*chequebook.SignedCheque, error) {

lastReceivedCheque := &chequebook.SignedCheque{
Cheque: chequebook.Cheque{
Beneficiary: beneficiary0,
Expand Down Expand Up @@ -494,6 +498,7 @@ func TestChequebookLastChequesPeer(t *testing.T) {
if !reflect.DeepEqual(got, expected) {
t.Fatalf("Got: \n %+v \n\n Expected: \n %+v \n\n", got, expected)
}

}

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

func LastChequesEqual(a, b *api.ChequebookLastChequesResponse) bool {

var state bool

for akeys := range a.LastCheques {
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (
"strconv"

"github.com/ethersphere/bee/v2/pkg/cac"
"github.com/ethersphere/bee/v2/pkg/soc"

"github.com/ethersphere/bee/v2/pkg/jsonhttp"
"github.com/ethersphere/bee/v2/pkg/postage"
"github.com/ethersphere/bee/v2/pkg/soc"
"github.com/ethersphere/bee/v2/pkg/storage"
"github.com/ethersphere/bee/v2/pkg/swarm"
"github.com/gorilla/mux"
Expand Down
9 changes: 5 additions & 4 deletions pkg/api/chunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ import (
"testing"
"time"

"github.com/ethersphere/bee/v2/pkg/api"
"github.com/ethersphere/bee/v2/pkg/jsonhttp"
"github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest"
"github.com/ethersphere/bee/v2/pkg/log"
mockbatchstore "github.com/ethersphere/bee/v2/pkg/postage/batchstore/mock"
mockpost "github.com/ethersphere/bee/v2/pkg/postage/mock"
"github.com/ethersphere/bee/v2/pkg/spinlock"
testingc "github.com/ethersphere/bee/v2/pkg/storage/testing"
mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock"

"github.com/ethersphere/bee/v2/pkg/api"
"github.com/ethersphere/bee/v2/pkg/jsonhttp"
"github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest"
testingc "github.com/ethersphere/bee/v2/pkg/storage/testing"
"github.com/ethersphere/bee/v2/pkg/swarm"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/api/cors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func TestCORSHeaders(t *testing.T) {
}
})
}

}

// TestCors tests whether CORs work correctly with OPTIONS method
Expand All @@ -134,8 +135,7 @@ func TestCors(t *testing.T) {
{
endpoint: "bzz",
expectedMethods: "POST",
},
{
}, {
endpoint: "bzz/0101011",
expectedMethods: "GET, HEAD",
},
Expand Down
1 change: 1 addition & 0 deletions pkg/api/debugstorage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ func TestDebugStorage(t *testing.T) {
jsonhttptest.WithExpectedJSONResponse(want),
)
})

}
1 change: 1 addition & 0 deletions pkg/api/dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func storeDir(
errorFilename string,
rLevel redundancy.Level,
) (swarm.Address, error) {

logger := tracing.NewLoggerWithTraceID(ctx, log)
loggerV1 := logger.V(1).Build()

Expand Down
7 changes: 5 additions & 2 deletions pkg/api/dirs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ func TestDirs(t *testing.T) {
// check error document
validateAltPath(t, "_non_existent_file_path_", errorDocumentPath)
}

}
t.Run(tc.name, func(t *testing.T) {
t.Run("tar_upload", func(t *testing.T) {
Expand Down Expand Up @@ -541,7 +542,7 @@ func tarFiles(t *testing.T, files []f) *bytes.Buffer {
// create tar header and write it
hdr := &tar.Header{
Name: filePath,
Mode: 0o600,
Mode: 0600,
Size: int64(len(file.data)),
}
if err := tw.WriteHeader(hdr); err != nil {
Expand Down Expand Up @@ -570,7 +571,7 @@ func tarEmptyDir(t *testing.T) *bytes.Buffer {

hdr := &tar.Header{
Name: "empty/",
Mode: 0o600,
Mode: 0600,
}

if err := tw.WriteHeader(hdr); err != nil {
Expand Down Expand Up @@ -603,9 +604,11 @@ func multipartFiles(t *testing.T, files []f) (*bytes.Buffer, string) {
contentType := file.header.Get(api.ContentTypeHeader)
if contentType != "" {
hdr.Set(api.ContentTypeHeader, contentType)

}
if len(file.data) > 0 {
hdr.Set(api.ContentLengthHeader, strconv.Itoa(len(file.data)))

}
part, err := mw.CreatePart(hdr)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/api/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ var (
EmptyDir = errEmptyDir
)

var ContentTypeTar = contentTypeTar
var (
ContentTypeTar = contentTypeTar
)

var (
ErrNoResolver = errNoResolver
Expand Down Expand Up @@ -137,7 +139,6 @@ type HexInvalidByteError = hexInvalidByteError
func MapStructure(input, output interface{}, hooks map[string]func(v string) (string, error)) error {
return mapStructure(input, output, hooks)
}

func NewParseError(entry, value string, cause error) error {
return newParseError(entry, value, cause)
}
1 change: 1 addition & 0 deletions pkg/api/feed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func TestFeed_Post(t *testing.T) {
)
})
})

}

// TestDirectUploadFeed tests that the direct upload endpoint give correct error message in dev mode
Expand Down
1 change: 1 addition & 0 deletions pkg/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func newMetrics() metrics {
}

func toFileSizeBucket(bytes int64) int64 {

for _, s := range fileSizeBucketsKBytes {
if (s * bytesInKB) >= bytes {
return s * bytesInKB
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/pin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func TestPinHandlers(t *testing.T) {
rootHash = strings.Trim(header.Get(api.ETagHeader), "\"")
checkPinHandlers(t, client, rootHash, false)
})

}

func TestPinHandlersInvalidInputs(t *testing.T) {
Expand Down Expand Up @@ -193,6 +194,7 @@ func TestPinHandlersInvalidInputs(t *testing.T) {
const pinRef = "620fcd78c7ce54da2d1b7cc2274a02e190cbe8fecbc3bd244690ab6517ce8f39"

func TestIntegrityHandler(t *testing.T) {

t.Parallel()

t.Run("ok", func(t *testing.T) {
Expand Down
5 changes: 4 additions & 1 deletion pkg/api/postage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"time"

"github.com/ethereum/go-ethereum/common"

"github.com/ethersphere/bee/v2/pkg/api"
"github.com/ethersphere/bee/v2/pkg/bigint"
"github.com/ethersphere/bee/v2/pkg/jsonhttp"
Expand Down Expand Up @@ -372,6 +373,7 @@ func TestPostageGetBuckets(t *testing.T) {

jsonhttptest.Request(t, tsNotFound, http.MethodGet, "/stamps/"+batchOkStr+"/buckets", http.StatusNotFound)
})

}

func TestReserveState(t *testing.T) {
Expand Down Expand Up @@ -404,7 +406,6 @@ func TestReserveState(t *testing.T) {
)
})
}

func TestChainState(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -432,6 +433,7 @@ func TestChainState(t *testing.T) {
}),
)
})

}

func TestPostageTopUpStamp(t *testing.T) {
Expand Down Expand Up @@ -701,6 +703,7 @@ func TestPostageDiluteStamp(t *testing.T) {
TxHash: txHash.String(),
}),
)

})
}

Expand Down
1 change: 1 addition & 0 deletions pkg/api/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (p *Probe) Healthy() ProbeStatus {
return ProbeStatusNOK
}
return p.healthy.get()

}

// SetHealthy updates the value of the healthy status.
Expand Down
11 changes: 5 additions & 6 deletions pkg/api/pss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func TestPssWebsocketSingleHandlerDeregister(t *testing.T) {
)

err := cl.SetReadDeadline(time.Now().Add(longTimeout))

if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -445,12 +446,10 @@ func TestPssPostHandlerInvalidInputs(t *testing.T) {
}
}

type (
pssSendFn func(context.Context, pss.Targets, swarm.Chunk) error
mpss struct {
f pssSendFn
}
)
type pssSendFn func(context.Context, pss.Targets, swarm.Chunk) error
type mpss struct {
f pssSendFn
}

func newMockPss(f pssSendFn) *mpss {
return &mpss{f}
Expand Down
1 change: 1 addition & 0 deletions pkg/api/settlements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestSettlements(t *testing.T) {
if !equalSettlements(got, expected) {
t.Errorf("got settlements: %+v, expected: %+v", got, expected)
}

}

func TestSettlementsError(t *testing.T) {
Expand Down
Loading

0 comments on commit 2098dc0

Please sign in to comment.