Skip to content

Commit

Permalink
Wait for the protocol 21 upgrade to propagate
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Apr 22, 2024
1 parent 2ac55a3 commit cea5134
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FAILURE_SAFETY=0
ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true
# Lower the TTL of persistent ledger entries
# so that ledger entry extension/restoring becomes testeable
TESTING_MINIMUM_PERSISTENT_ENTRY_LIFETIME=10
TESTING_MINIMUM_PERSISTENT_ENTRY_LIFETIME=40
TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true

[[VALIDATORS]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DATABASE="postgresql://user=postgres password=mysecretpassword host=core-postgre

# Lower the TTL of persistent ledger entries
# so that ledger entry extension/restoring becomes testeable
TESTING_MINIMUM_PERSISTENT_ENTRY_LIFETIME=10
TESTING_MINIMUM_PERSISTENT_ENTRY_LIFETIME=40
TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE=true

[QUORUM_SET]
Expand Down
22 changes: 22 additions & 0 deletions cmd/soroban-rpc/internal/test/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package test

import (
"context"
"testing"
"time"

"github.com/creachadair/jrpc2"
"github.com/creachadair/jrpc2/jhttp"
"github.com/stellar/go/keypair"
"github.com/stellar/go/txnbuild"
"github.com/stellar/go/xdr"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/db"
)

func TestUpgradeFrom20To21(t *testing.T) {
Expand Down Expand Up @@ -47,6 +52,23 @@ func TestUpgradeFrom20To21(t *testing.T) {
// Upgrade to protocol 21 and re-upload the contract, which should cause a caching of the contract
// estimations
test.UpgradeProtocol(21)
// Wait for the protocol version to propagate, so that the simulation library passes the right protocol
foundProtocol := uint32(0)
for i := 0; i < 60; i++ {
rpcDB := test.daemon.GetDB()
time.Sleep(time.Second)
lReader := db.NewLedgerReader(rpcDB)
latestLedgerSequence, err := db.NewLedgerEntryReader(rpcDB).GetLatestLedgerSequence(context.Background())
require.NoError(t, err)
latestLedger, present, err := lReader.GetLedger(context.Background(), latestLedgerSequence)
require.NoError(t, err)
require.True(t, present)
foundProtocol = uint32(latestLedger.V1.LedgerHeader.Header.LedgerVersion)
if foundProtocol == 21 {
break
}
}
require.Equal(t, uint32(21), foundProtocol, "rpc didn't start ingesting protocol 21")

params = preflightTransactionParams(t, client, txnbuild.TransactionParams{
SourceAccount: &account,
Expand Down

0 comments on commit cea5134

Please sign in to comment.