Skip to content

Commit

Permalink
refactor: remove testcontainers dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
vfusco committed Oct 9, 2024
1 parent d2a63a9 commit e0e3848
Show file tree
Hide file tree
Showing 33 changed files with 515 additions and 1,288 deletions.
2 changes: 1 addition & 1 deletion cmd/cartesi-rollups-cli/root/app/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

var Cmd = &cobra.Command{
Use: "add",
Short: "Adds a new application",
Short: "Add an existing application to the node",
Example: examples,
Run: run,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cartesi-rollups-cli/root/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func init() {
&common.PostgresEndpoint,
"postgres-endpoint",
"p",
"postgres://postgres:password@localhost:5432/postgres",
"postgres://postgres:password@localhost:5432/rollupsdb?sslmode=disable",
"Postgres endpoint",
)

Expand Down
103 changes: 0 additions & 103 deletions cmd/cartesi-rollups-cli/root/deps/deps.go

This file was deleted.

13 changes: 7 additions & 6 deletions cmd/cartesi-rollups-cli/root/execute/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/cartesi/rollups-node/pkg/addresses"
"github.com/cartesi/rollups-node/pkg/ethutil"
"github.com/cartesi/rollups-node/pkg/readerclient"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -58,8 +59,8 @@ func init() {
Cmd.Flags().Uint32Var(&account, "account", 0,
"account index used to sign the transaction (default: 0)")

Cmd.Flags().StringVar(&addressBookFile, "address-book", "",
"if set, load the address book from the given file; else, use test addresses")
Cmd.Flags().StringVar(&addressBookFile, "address-book", "deployment.json",
"if set, load the address book from the given file; else from deployment.json")
}

func run(cmd *cobra.Command, args []string) {
Expand All @@ -85,21 +86,21 @@ func run(cmd *cobra.Command, args []string) {
if addressBookFile != "" {
book, err = addresses.GetBookFromFile(addressBookFile)
cobra.CheckErr(err)
} else {
book = addresses.GetTestBook()
}

proof := readerclient.ConvertToContractProof(resp.Proof)

appAddr := common.HexToAddress("0x0000000000000000000000000000000000000000") // FIXME

slog.Info("Executing voucher",
"voucher-index", voucherIndex,
"input-index", inputIndex,
"application-address", book.Application,
)
"application-address", appAddr)
txHash, err := ethutil.ExecuteOutput(
ctx,
client,
book,
appAddr,
signer,
resp.Payload,
proof,
Expand Down
4 changes: 0 additions & 4 deletions cmd/cartesi-rollups-cli/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import (
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/app"
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/db"

"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/deps"
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/execute"
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/increasetime"
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/inspect"
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/mine"
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/read"
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/savesnapshot"
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/send"
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/validate"
"github.com/lmittmann/tint"
Expand All @@ -40,11 +38,9 @@ func init() {

Cmd.AddCommand(send.Cmd)
Cmd.AddCommand(read.Cmd)
Cmd.AddCommand(savesnapshot.Cmd)
Cmd.AddCommand(inspect.Cmd)
Cmd.AddCommand(increasetime.Cmd)
Cmd.AddCommand(validate.Cmd)
Cmd.AddCommand(deps.Cmd)
Cmd.AddCommand(execute.Cmd)
Cmd.AddCommand(mine.Cmd)
Cmd.AddCommand(app.Cmd)
Expand Down
42 changes: 0 additions & 42 deletions cmd/cartesi-rollups-cli/root/savesnapshot/savesnapshot.go

This file was deleted.

13 changes: 7 additions & 6 deletions cmd/cartesi-rollups-cli/root/send/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/cartesi/rollups-node/pkg/addresses"
"github.com/cartesi/rollups-node/pkg/ethutil"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -46,8 +47,8 @@ func init() {

cobra.CheckErr(Cmd.MarkFlagRequired("payload"))

Cmd.Flags().StringVar(&addressBookFile, "address-book", "",
"if set, load the address book from the given file; else, use test addresses")
Cmd.Flags().StringVar(&addressBookFile, "address-book", "deployment.json",
"if set, load the address book from the given file; else from deployment.json")
}

func run(cmd *cobra.Command, args []string) {
Expand All @@ -66,12 +67,12 @@ func run(cmd *cobra.Command, args []string) {
if addressBookFile != "" {
book, err = addresses.GetBookFromFile(addressBookFile)
cobra.CheckErr(err)
} else {
book = addresses.GetTestBook()
}

slog.Info("Sending input", "application-address", book.Application)
inputIndex, err := ethutil.AddInput(ctx, client, book, signer, payload)
appAddr := common.HexToAddress("0x0000000000000000000000000000000000000000") // FIXME

slog.Info("Sending input", "application-address", appAddr)
inputIndex, err := ethutil.AddInput(ctx, client, book, appAddr, signer, payload)
cobra.CheckErr(err)

slog.Info("Input added", "input-index", inputIndex)
Expand Down
13 changes: 7 additions & 6 deletions cmd/cartesi-rollups-cli/root/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/cartesi/rollups-node/pkg/addresses"
"github.com/cartesi/rollups-node/pkg/ethutil"
"github.com/cartesi/rollups-node/pkg/readerclient"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -50,8 +51,8 @@ func init() {
Cmd.Flags().StringVar(&ethEndpoint, "eth-endpoint", "http://localhost:8545",
"ethereum node JSON-RPC endpoint")

Cmd.Flags().StringVar(&addressBookFile, "address-book", "",
"if set, load the address book from the given file; else, use test addresses")
Cmd.Flags().StringVar(&addressBookFile, "address-book", "deployment.json",
"if set, load the address book from the given file; else from deployment.json")
}

func run(cmd *cobra.Command, args []string) {
Expand All @@ -74,18 +75,18 @@ func run(cmd *cobra.Command, args []string) {
if addressBookFile != "" {
book, err = addresses.GetBookFromFile(addressBookFile)
cobra.CheckErr(err)
} else {
book = addresses.GetTestBook()
}

proof := readerclient.ConvertToContractProof(resp.Proof)

appAddr := common.HexToAddress("0x0000000000000000000000000000000000000000") // FIXME

slog.Info("Validating notice",
"notice-index", noticeIndex,
"input-index", inputIndex,
"application-address", book.Application,
"application-address", appAddr,
)
err = ethutil.ValidateOutput(ctx, client, book, resp.Payload, proof)
err = ethutil.ValidateOutput(ctx, client, book, appAddr, resp.Payload, proof)
cobra.CheckErr(err)

slog.Info("Notice validated")
Expand Down
10 changes: 5 additions & 5 deletions cmd/cartesi-rollups-node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ func main() {
startup.ConfigLogs(config.LogLevel, config.LogPrettyEnabled)
slog.Info("Starting the Cartesi Rollups Node", "version", buildVersion, "config", config)

err := startup.ValidateSchema(config.PostgresEndpoint.Value)
database, err := repository.Connect(ctx, config.PostgresEndpoint.Value)
if err != nil {
slog.Error("Node exited with an error", "error", err)
slog.Error("Node couldn't connect to the database", "error", err)
os.Exit(1)
}
defer database.Close()

database, err := repository.Connect(ctx, config.PostgresEndpoint.Value)
err = startup.ValidateSchema(config.PostgresEndpoint.Value)
if err != nil {
slog.Error("Node couldn't connect to the database", "error", err)
slog.Error("Node exited with an error", "error", err)
os.Exit(1)
}
defer database.Close()

_, err = startup.SetupNodePersistentConfig(ctx, database, config)
if err != nil {
Expand Down
Loading

0 comments on commit e0e3848

Please sign in to comment.