Skip to content

Commit

Permalink
fix: integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Oct 23, 2024
1 parent 072e007 commit 2038522
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,24 +212,16 @@ func mustMakeDisperser(t *testing.T, cst core.IndexedChainState, store disperser
tx.On("GetCurrentBlockNumber").Return(uint64(100), nil)
tx.On("GetQuorumCount").Return(1, nil)

minimumNumSymbols := uint32(128)
pricePerSymbol := uint32(1)
reservationLimit := uint64(1024)
paymentLimit := big.NewInt(512)
meterConfig := meterer.Config{
GlobalSymbolsPerSecond: 1024,
PricePerSymbol: pricePerSymbol,
MinNumSymbols: minimumNumSymbols,
ReservationWindow: uint32(60),
}

// this is disperser client's private key used in tests
privateKey, err := crypto.HexToECDSA("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcded") // Remove "0x" prefix
if err != nil {
panic("failed to convert hex to ECDSA")
}
publicKey := crypto.PubkeyToAddress(privateKey.PublicKey).Hex()

mockState := &coremock.MockOnchainPaymentState{}
reservationLimit := uint64(1024)
paymentLimit := big.NewInt(512)
mockState.On("GetActiveReservationByAccount", mock.Anything, mock.MatchedBy(func(account string) bool {
return account == publicKey
})).Return(core.ActiveReservation{SymbolsPerSec: reservationLimit, StartTimestamp: 0, EndTimestamp: math.MaxUint32, QuorumSplit: []byte{50, 50}, QuorumNumbers: []uint8{0, 1}}, nil)
Expand All @@ -240,6 +232,10 @@ func mustMakeDisperser(t *testing.T, cst core.IndexedChainState, store disperser
})).Return(core.OnDemandPayment{CumulativePayment: paymentLimit}, nil)
mockState.On("GetOnDemandPaymentByAccount", mock.Anything, mock.Anything).Return(core.OnDemandPayment{}, errors.New("payment not found"))
mockState.On("GetOnDemandQuorumNumbers", mock.Anything).Return([]uint8{0, 1}, nil)
mockState.On("GetGlobalSymbolsPerSecond", mock.Anything).Return(uint64(1024), nil)
mockState.On("GetPricePerSymbol", mock.Anything).Return(uint32(1), nil)
mockState.On("GetMinNumSymbols", mock.Anything).Return(uint32(128), nil)
mockState.On("GetReservationWindow", mock.Anything).Return(uint32(60), nil)

deployLocalStack = !(os.Getenv("DEPLOY_LOCALSTACK") == "false")
if !deployLocalStack {
Expand Down Expand Up @@ -272,7 +268,7 @@ func mustMakeDisperser(t *testing.T, cst core.IndexedChainState, store disperser
if err != nil {
panic("failed to create offchain store")
}
meterer := meterer.NewMeterer(meterConfig, mockState, offchainStore, logger)
meterer := meterer.NewMeterer(meterer.Config{}, mockState, offchainStore, logger)
server := apiserver.NewDispersalServer(serverConfig, store, tx, logger, disperserMetrics, meterer, ratelimiter, rateConfig, testMaxBlobSize)

return TestDisperser{
Expand Down

0 comments on commit 2038522

Please sign in to comment.