Skip to content

Commit

Permalink
chore: test fix and startup query
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Oct 25, 2024
1 parent 4218aba commit 253c00f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
5 changes: 5 additions & 0 deletions core/meterer/meterer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func (m *Meterer) Start(ctx context.Context) {
ticker := time.NewTicker(1 * time.Hour)
defer ticker.Stop()

// initial tick immediately upto Start
if err := m.ChainState.RefreshOnchainPaymentState(ctx, nil); err != nil {
m.logger.Error("Failed to make initial query to the on-chain state", "error", err)
}

for {
select {
case <-ticker.C:
Expand Down
6 changes: 3 additions & 3 deletions core/meterer/meterer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ var (
deployLocalStack bool
localStackPort = "4566"
paymentChainState = &mock.MockOnchainPaymentState{}
ondemandTableName = "ondemand-meterer-test"
reservationTableName = "reservations-meterer-test"
globalReservationTableName = "global-reservation-meterer-test"
ondemandTableName = "ondemand_meterer"
reservationTableName = "reservations_meterer"
globalReservationTableName = "global_reservation_meterer"
)

func TestMain(m *testing.M) {
Expand Down
14 changes: 8 additions & 6 deletions disperser/apiserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var (
bucketTableName = fmt.Sprintf("test-BucketStore-%v", UUID)

deployLocalStack bool
localStackPort = "4568"
localStackPort = "4569"
allowlistFile *os.File
testMaxBlobSize = 2 * 1024 * 1024
)
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestDisperseBlobWithRequiredQuorums(t *testing.T) {
}
transactor.On("GetQuorumSecurityParams", tmock.Anything).Return(quorumParams, nil)

dispersalServer := newTestServer(transactor)
dispersalServer := newTestServer(transactor, t.Name())

data := make([]byte, 1024)
_, err := rand.Read(data)
Expand Down Expand Up @@ -193,6 +193,7 @@ func TestDisperseBlobWithRequiredQuorums(t *testing.T) {
}

func TestDisperseBlobWithInvalidQuorum(t *testing.T) {

data := make([]byte, 1024)
_, err := rand.Read(data)
assert.NoError(t, err)
Expand All @@ -207,6 +208,7 @@ func TestDisperseBlobWithInvalidQuorum(t *testing.T) {
}
ctx := peer.NewContext(context.Background(), p)

// (*dispersalServer).tx.On("GetRequiredQuorumNumbers", tmock.Anything).Return([]uint8{0, 1}, nil).Twice()
_, err = dispersalServer.DisperseBlob(ctx, &pb.DisperseBlobRequest{
Data: data,
CustomQuorumNumbers: []uint32{2},
Expand Down Expand Up @@ -605,7 +607,7 @@ func setup() {
transactor.On("GetQuorumSecurityParams", tmock.Anything).Return(quorumParams, nil)
transactor.On("GetRequiredQuorumNumbers", tmock.Anything).Return([]uint8{}, nil)

dispersalServer = newTestServer(transactor)
dispersalServer = newTestServer(transactor, "setup")
dispersalServerV2 = newTestServerV2()
}

Expand All @@ -618,7 +620,7 @@ func teardown() {
}
}

func newTestServer(transactor core.Writer) *apiserver.DispersalServer {
func newTestServer(transactor core.Writer, testName string) *apiserver.DispersalServer {
logger := logging.NewNoopLogger()

bucketName := "test-eigenda-blobstore"
Expand Down Expand Up @@ -650,8 +652,8 @@ func newTestServer(transactor core.Writer) *apiserver.DispersalServer {

mockState := &mock.MockOnchainPaymentState{}

table_names := []string{"reservations-apiserver-test", "ondemand-apiserver-test", "global-apiserver-test"}

// append test name to each table name for an unique store
table_names := []string{"reservations_server_" + testName, "ondemand_server_" + testName, "global_server_" + testName}
err = meterer.CreateReservationTable(awsConfig, table_names[0])
if err != nil {
teardown()
Expand Down
2 changes: 1 addition & 1 deletion test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func mustMakeDisperser(t *testing.T, cst core.IndexedChainState, store disperser
EndpointURL: fmt.Sprintf("http://0.0.0.0:%s", localStackPort),
}

table_names := []string{"reservations-integration-test", "ondemand-integration-test", "global-integration-test"}
table_names := []string{"reservations_integration", "ondemand_integration", "global_integration"}

err = meterer.CreateReservationTable(clientConfig, table_names[0])
if err != nil {
Expand Down

0 comments on commit 253c00f

Please sign in to comment.