Fix serialization of payment hash db (#579)

* Use postgres for db in itest

* Fix serialization of payment hash in db tables
This commit is contained in:
Jonathan Zernik 2021-01-08 00:48:16 -08:00 committed by GitHub
parent c984d41bcc
commit cede35ed55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 4 deletions

3
createdb.sql Normal file
View file

@ -0,0 +1,3 @@
CREATE DATABASE squeaknode;
\connect squeaknode;

View file

@ -70,6 +70,17 @@ services:
- net.ipv6.conf.all.disable_ipv6=0
entrypoint: ["./start-lnd.sh"]
squeaknode_db:
image: postgres
container_name: test_squeaknode_db
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- ../createdb.sql:/docker-entrypoint-initdb.d/init.sql
- squeaknode_pgdata:/var/lib/postgresql
squeaknode:
image: squeaknode
container_name: test_squeaknode
@ -78,6 +89,9 @@ services:
dockerfile: Dockerfile
depends_on:
- "lnd_server"
- "squeaknode_db"
environment:
- SQUEAKNODE_DB_CONNECTION_STRING=postgresql://postgres:postgres@squeaknode_db/squeaknode
volumes:
- test_shared:/rpc
- test_lnd_server_dir:/root/.lnd
@ -85,6 +99,7 @@ services:
links:
- "btcd:btcd"
- "lnd_server:lnd"
- "squeaknode_db:squeaknode_db"
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
entrypoint: ["./start-squeaknode.sh"]
@ -136,3 +151,7 @@ volumes:
driver: local
test_lnd_server_dir:
driver: local
# postgres db data
squeaknode_pgdata:
driver: local

View file

@ -932,7 +932,7 @@ class SqueakDb:
def insert_sent_offer(self, sent_offer):
""" Insert a new sent offer. """
ins = self.sent_offers.insert().values(
squeak_hash=sent_offer.squeak_hash,
squeak_hash=sent_offer.squeak_hash.hex(),
payment_hash=sent_offer.payment_hash,
secret_key=sent_offer.secret_key,
nonce=sent_offer.nonce.hex(),
@ -1008,7 +1008,7 @@ class SqueakDb:
def insert_received_payment(self, received_payment):
""" Insert a new received payment. """
ins = self.received_payments.insert().values(
squeak_hash=received_payment.squeak_hash,
squeak_hash=received_payment.squeak_hash.hex(),
payment_hash=received_payment.payment_hash,
price_msat=received_payment.price_msat,
settle_index=received_payment.settle_index,
@ -1161,7 +1161,7 @@ class SqueakDb:
return None
return SentOffer(
sent_offer_id=row["sent_offer_id"],
squeak_hash=row["squeak_hash"],
squeak_hash=bytes.fromhex(row["squeak_hash"]),
payment_hash=row["payment_hash"],
secret_key=row["secret_key"],
nonce=bytes.fromhex(row["nonce"]),
@ -1178,7 +1178,7 @@ class SqueakDb:
return ReceivedPayment(
received_payment_id=row["received_payment_id"],
created=row["created"],
squeak_hash=row["squeak_hash"],
squeak_hash=bytes.fromhex(row["squeak_hash"]),
payment_hash=row["payment_hash"],
price_msat=row["price_msat"],
settle_index=row["settle_index"],