Merge pull request #120 from blockworks-foundation/postgres_test_migration_fix

postgres migration and test script fix
This commit is contained in:
galactus 2023-04-15 10:02:54 +02:00 committed by GitHub
commit 65c5d8365c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -16,9 +16,9 @@ CREATE TABLE lite_rpc.Txs (
CREATE TABLE lite_rpc.Blocks (
slot BIGINT NOT NULL PRIMARY KEY,
leader_id BIGINT NOT NULL,
parent_slot BIGINT NOT NULL
parent_slot BIGINT NOT NULL,
cluster_time TIMESTAMP WITH TIME ZONE NOT NULL,
local_time TIMESTAMP WITH TIME ZONE,
local_time TIMESTAMP WITH TIME ZONE
);
CREATE TABLE lite_rpc.AccountAddrs (

View File

@ -92,7 +92,6 @@ impl PostgresSession {
let ca_pem = BinaryEncoding::Base64
.decode(ca_pem_b64)
.context("ca pem decode")?;
let client_pks = BinaryEncoding::Base64
.decode(client_pks_b64)
.context("client pks decode")?;
@ -346,13 +345,13 @@ impl Postgres {
);
if let Err(err) = res_txs {
warn!("Error sending tx batch to postgres {err:?}");
warn!("Error sending tx batch ({:?}) to postgres {err:?}", tx_que.len());
} else {
tx_que.clear();
}
if let Err(err) = res_block {
warn!("Error sending block batch to postgres {err:?}");
warn!("Error sending block batch ({:?}) to postgres {err:?}", block_que.len());
} else {
block_que.clear();
}

View File

@ -1,5 +1,8 @@
#!/bin/sh
# kill background jobs on exit/failure
trap 'kill $(jobs -pr)' SIGINT SIGTERM EXIT
# env variables
export PGPASSWORD="password"
export PG_CONFIG="host=localhost dbname=postgres user=postgres password=password sslmode=disable"
@ -16,6 +19,12 @@ docker start test-postgres
echo "Clearing database"
pg_run -f ../migrations/rm.sql
pg_run -f ../migrations/create.sql
echo "Starting the test validator"
solana-test-validator > /dev/null &
echo "Waiting 8 seconds for solana-test-validator to start"
sleep 8
echo "Starting lite-rpc"
cargo run --release -- -p &