docs: update sqlx script and add ci

- upgrades sqlx to 0.6
- fixes sqlite_dev_setup.sh script
- adds ci to test the script
This commit is contained in:
Byron Hambly 2022-11-30 13:39:20 +02:00
parent f0e28b1bc6
commit f0e059c814
No known key found for this signature in database
GPG Key ID: DE8F6EA20A661697
7 changed files with 166 additions and 114 deletions

View File

@ -40,6 +40,22 @@ jobs:
- name: Run BDK regression script
run: ./swap/tests/bdk.sh
sqlx_test:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3.1.0
- uses: Swatinem/rust-cache@v2.0.2
- name: Install sqlx-cli
run: cargo install sqlx-cli
- name: Run sqlite_dev_setup.sh script
run: |
cd swap
./sqlite_dev_setup.sh
build:
strategy:
matrix:

1
.gitignore vendored
View File

@ -160,3 +160,4 @@ flycheck_*.el
*.log
.vscode
swap/tempdb

150
Cargo.lock generated
View File

@ -45,9 +45,9 @@ dependencies = [
[[package]]
name = "ahash"
version = "0.7.4"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
"getrandom 0.2.6",
"once_cell",
@ -150,9 +150,9 @@ dependencies = [
[[package]]
name = "atoi"
version = "0.4.0"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "616896e05fc0e2649463a93a15183c6a16bf03413a7af88ef1285ddedfa9cda5"
checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e"
dependencies = [
"num-traits",
]
@ -508,9 +508,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
version = "1.0.1"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c"
[[package]]
name = "bzip2"
@ -731,18 +731,18 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
[[package]]
name = "crc"
version = "2.0.0"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10c2722795460108a7872e1cd933a85d6ec38abc4baecad51028f702da28889f"
checksum = "53757d12b596c16c78b83458d732a5d1a17ab3f53f2f7412f6fb57cc8a140ab3"
dependencies = [
"crc-catalog",
]
[[package]]
name = "crc-catalog"
version = "1.1.1"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccaeedb56da03b09f598226e25e80088cb4cd25f316e6e4df7d695f0feeb1403"
checksum = "2d0165d2900ae6778e36e80bbc4da3b5eefccee9ba939761f9c2882a5d9af3ff"
[[package]]
name = "crc32fast"
@ -778,9 +778,9 @@ dependencies = [
[[package]]
name = "crossbeam-queue"
version = "0.3.1"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f6cb3c7f5b8e51bc3ebb73a2327ad4abdbd119dc13223f14f961d2f38486756"
checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
@ -1010,10 +1010,10 @@ dependencies = [
]
[[package]]
name = "dotenv"
version = "0.15.0"
name = "dotenvy"
version = "0.15.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0"
[[package]]
name = "dtoa"
@ -1129,6 +1129,12 @@ dependencies = [
"syn",
]
[[package]]
name = "event-listener"
version = "2.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]]
name = "fastrand"
version = "1.7.0"
@ -1181,6 +1187,18 @@ dependencies = [
"miniz_oxide",
]
[[package]]
name = "flume"
version = "0.10.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577"
dependencies = [
"futures-core",
"futures-sink",
"pin-project 1.0.5",
"spin 0.9.4",
]
[[package]]
name = "fnv"
version = "1.0.7"
@ -1458,11 +1476,11 @@ dependencies = [
[[package]]
name = "hashlink"
version = "0.7.0"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf"
checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa"
dependencies = [
"hashbrown 0.11.2",
"hashbrown 0.12.3",
]
[[package]]
@ -1479,6 +1497,9 @@ name = "heck"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "hermit-abi"
@ -2100,9 +2121,9 @@ dependencies = [
[[package]]
name = "libsqlite3-sys"
version = "0.22.2"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290b64917f8b0cb885d9de0f9959fe1f775d7fa12f1da2db9001c1c8ab60f89d"
checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14"
dependencies = [
"cc",
"pkg-config",
@ -2616,6 +2637,12 @@ dependencies = [
"windows-sys 0.32.0",
]
[[package]]
name = "paste"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1"
[[package]]
name = "pem"
version = "1.1.0"
@ -2938,9 +2965,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.9"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
dependencies = [
"proc-macro2",
]
@ -3196,7 +3223,7 @@ dependencies = [
"cc",
"libc",
"once_cell",
"spin",
"spin 0.5.2",
"untrusted",
"web-sys",
"winapi",
@ -3519,7 +3546,6 @@ version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
dependencies = [
"indexmap",
"itoa 1.0.1",
"ryu",
"serde",
@ -3690,9 +3716,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.6.1"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "snow"
@ -3765,10 +3791,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "sqlformat"
version = "0.1.8"
name = "spin"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4b7922be017ee70900be125523f38bdd644f4f06a1b16e8fa5a8ee8c34bffd4"
checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09"
dependencies = [
"lock_api",
]
[[package]]
name = "sqlformat"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f87e292b4291f154971a43c3774364e2cbcaec599d3f5bf6fa9d122885dbc38a"
dependencies = [
"itertools",
"nom 7.0.0",
@ -3777,9 +3812,9 @@ dependencies = [
[[package]]
name = "sqlx"
version = "0.5.9"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7911b0031a0247af40095838002999c7a52fba29d9739e93326e71a5a1bc9d43"
checksum = "9249290c05928352f71c077cc44a464d880c63f26f7534728cca008e135c0428"
dependencies = [
"sqlx-core",
"sqlx-macros",
@ -3787,9 +3822,9 @@ dependencies = [
[[package]]
name = "sqlx-core"
version = "0.5.9"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aec89bfaca8f7737439bad16d52b07f1ccd0730520d3bf6ae9d069fe4b641fb1"
checksum = "dcbc16ddba161afc99e14d1713a453747a2b07fc097d2009f4c300ec99286105"
dependencies = [
"ahash",
"atoi",
@ -3797,28 +3832,31 @@ dependencies = [
"byteorder",
"bytes",
"crc",
"crossbeam-channel",
"crossbeam-queue",
"crossbeam-utils",
"dotenvy",
"either",
"event-listener",
"flume",
"futures-channel",
"futures-core",
"futures-executor",
"futures-intrusive",
"futures-util",
"hashlink",
"hex",
"indexmap",
"itoa 0.4.7",
"itoa 1.0.1",
"libc",
"libsqlite3-sys",
"log",
"memchr",
"once_cell",
"parking_lot 0.11.2",
"paste",
"percent-encoding",
"rustls 0.19.0",
"rustls 0.20.2",
"rustls-pemfile",
"serde",
"sha2 0.9.8",
"sha2 0.10.6",
"smallvec",
"sqlformat",
"sqlx-rt",
@ -3826,27 +3864,25 @@ dependencies = [
"thiserror",
"tokio-stream",
"url",
"webpki 0.21.4",
"webpki-roots 0.21.0",
"whoami",
"webpki-roots 0.22.2",
]
[[package]]
name = "sqlx-macros"
version = "0.5.9"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "584866c833511b1a152e87a7ee20dee2739746f60c858b3c5209150bc4b466f5"
checksum = "b850fa514dc11f2ee85be9d055c512aa866746adfacd1cb42d867d68e6a5b0d9"
dependencies = [
"dotenv",
"dotenvy",
"either",
"heck 0.3.2",
"heck 0.4.0",
"hex",
"once_cell",
"proc-macro2",
"quote",
"serde",
"serde_json",
"sha2 0.9.8",
"sha2 0.10.6",
"sqlx-core",
"sqlx-rt",
"syn",
@ -3855,13 +3891,13 @@ dependencies = [
[[package]]
name = "sqlx-rt"
version = "0.5.9"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d1bd069de53442e7a320f525a6d4deb8bb0621ac7a55f7eccbc2b58b57f43d0"
checksum = "24c5b2d25fa654cc5f841750b8e1cdedbe21189bf9a9382ee90bfa9dd3562396"
dependencies = [
"once_cell",
"tokio",
"tokio-rustls 0.22.0",
"tokio-rustls 0.23.1",
]
[[package]]
@ -4275,9 +4311,9 @@ dependencies = [
[[package]]
name = "tokio-stream"
version = "0.1.4"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c535f53c0cfa1acace62995a8994fc9cc1f12d202420da96ff306ee24d576469"
checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce"
dependencies = [
"futures-core",
"pin-project-lite 0.2.9",
@ -4901,16 +4937,6 @@ dependencies = [
"thiserror",
]
[[package]]
name = "whoami"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7741161a40200a867c96dfa5574544efa4178cf4c8f770b62dd1cc0362d7ae1"
dependencies = [
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "widestring"
version = "0.4.3"

View File

@ -1,6 +1,7 @@
status = [
"static_analysis",
"bdk_test",
"sqlx_test",
"build (x86_64-unknown-linux-gnu, ubuntu-latest)",
"build (armv7-unknown-linux-gnueabihf, ubuntu-latest)",
"build (x86_64-apple-darwin, macos-latest)",

View File

@ -48,7 +48,7 @@ serde_json = "1"
serde_with = { version = "1", features = [ "macros" ] }
sha2 = "0.10"
sigma_fun = { git = "https://github.com/LLFourn/secp256kfun", default-features = false, features = [ "ed25519", "serde", "secp256k1", "alloc" ] }
sqlx = { version = "0.5", features = [ "sqlite", "runtime-tokio-rustls", "offline" ] }
sqlx = { version = "0.6", features = [ "sqlite", "runtime-tokio-rustls", "offline" ] }
structopt = "0.3"
strum = { version = "0.24", features = [ "derive" ] }
thiserror = "1"

16
swap/sqlite_dev_setup.sh Normal file → Executable file
View File

@ -1,6 +1,14 @@
# crated temporary DB
# run the migration scripts to create the tables
# prepare the sqlx-data.json rust mappings
#!/bin/bash
# run this script from the swap dir
# make sure you have sqlx-cli installed: cargo install sqlx-cli
# this script creates a temporary sqlite database
# then runs the migration scripts to create the tables (migrations folder)
# then it prepares the offline sqlx-data.json rust mappings
DATABASE_URL=sqlite:tempdb cargo sqlx database create
DATABASE_URL=sqlite:tempdb cargo sqlx migrate run
DATABASE_URL=sqlite:./swap/tempdb cargo sqlx prepare -- --bin swap
# needs the absolute path here
# https://github.com/launchbadge/sqlx/issues/1399
DB_PATH=$(readlink -f tempdb)
DATABASE_URL="sqlite:$DB_PATH" cargo sqlx prepare -- --bin swap

View File

@ -1,7 +1,6 @@
{
"db": "SQLite",
"081c729a0f1ad6e4ff3e13d6702c946bc4d37d50f40670b4f51d2efcce595aa6": {
"query": "\n SELECT peer_id\n FROM peers\n WHERE swap_id = ?\n ",
"describe": {
"columns": [
{
@ -10,26 +9,26 @@
"type_info": "Text"
}
],
"parameters": {
"Right": 1
},
"nullable": [
false
]
],
"parameters": {
"Right": 1
}
},
"query": "\n SELECT peer_id\n FROM peers\n WHERE swap_id = ?\n "
},
"0ab84c094964968e96a3f2bf590d9ae92227d057386921e0e57165b887de3c75": {
"query": "\n insert into peer_addresses (\n peer_id,\n address\n ) values (?, ?);\n ",
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 2
},
"nullable": []
}
},
"query": "\n insert into peer_addresses (\n peer_id,\n address\n ) values (?, ?);\n "
},
"1ec38c85e7679b2eb42b3df75d9098772ce44fdb8db3012d3c2410d828b74157": {
"query": "\n SELECT swap_id, state\n FROM (\n SELECT max(id), swap_id, state\n FROM swap_states\n GROUP BY swap_id\n )\n ",
"describe": {
"columns": [
{
@ -43,37 +42,37 @@
"type_info": "Text"
}
],
"parameters": {
"Right": 0
},
"nullable": [
false,
false
]
],
"parameters": {
"Right": 0
}
},
"query": "\n SELECT swap_id, state\n FROM (\n SELECT max(id), swap_id, state\n FROM swap_states\n GROUP BY swap_id\n )\n "
},
"2a356078a41b321234adf2aa385b501749f907f7c422945a8bdda2b6274f5225": {
"query": "\n insert into peers (\n swap_id,\n peer_id\n ) values (?, ?);\n ",
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 2
},
"nullable": []
}
},
"query": "\n insert into peers (\n swap_id,\n peer_id\n ) values (?, ?);\n "
},
"50a5764546f69c118fa0b64120da50f51073d36257d49768de99ff863e3511e0": {
"query": "\n insert into monero_addresses (\n swap_id,\n address\n ) values (?, ?);\n ",
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 2
},
"nullable": []
}
},
"query": "\n insert into monero_addresses (\n swap_id,\n address\n ) values (?, ?);\n "
},
"88f761a4f7a0429cad1df0b1bebb1c0a27b2a45656549b23076d7542cfa21ecf": {
"query": "\n SELECT state\n FROM swap_states\n WHERE swap_id = ?\n ORDER BY id desc\n LIMIT 1;\n\n ",
"describe": {
"columns": [
{
@ -82,16 +81,16 @@
"type_info": "Text"
}
],
"parameters": {
"Right": 1
},
"nullable": [
false
]
],
"parameters": {
"Right": 1
}
},
"query": "\n SELECT state\n FROM swap_states\n WHERE swap_id = ?\n ORDER BY id desc\n LIMIT 1;\n\n "
},
"a0eb85d04ee3842c52291dad4d225941d1141af735922fcbc665868997fce304": {
"query": "\n SELECT address\n FROM peer_addresses\n WHERE peer_id = ?\n ",
"describe": {
"columns": [
{
@ -100,26 +99,26 @@
"type_info": "Text"
}
],
"parameters": {
"Right": 1
},
"nullable": [
false
]
],
"parameters": {
"Right": 1
}
},
"query": "\n SELECT address\n FROM peer_addresses\n WHERE peer_id = ?\n "
},
"b703032b4ddc627a1124817477e7a8e5014bdc694c36a14053ef3bb2fc0c69b0": {
"query": "\n insert into swap_states (\n swap_id,\n entered_at,\n state\n ) values (?, ?, ?);\n ",
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 3
},
"nullable": []
}
},
"query": "\n insert into swap_states (\n swap_id,\n entered_at,\n state\n ) values (?, ?, ?);\n "
},
"ce270dd4a4b9615695a79864240c5401e2122077365e5e5a19408c068c7f9454": {
"query": "\n SELECT address\n FROM monero_addresses\n WHERE swap_id = ?\n ",
"describe": {
"columns": [
{
@ -128,12 +127,13 @@
"type_info": "Text"
}
],
"parameters": {
"Right": 1
},
"nullable": [
false
]
}
],
"parameters": {
"Right": 1
}
},
"query": "\n SELECT address\n FROM monero_addresses\n WHERE swap_id = ?\n "
}
}