Skip to content

Commit 833e312

Browse files
authored
test: add repository property-based tests (#10)
* tests: add pbt for monitor repo and configs * chore: move integration tests into own folder * fix: config validation via load_all * tests: run with multiple inputs * tests: reduce input size * feat: recommend past blocks configuration * fix: integration test rpc url * fix: multiple network service inits * tests: add repository tests and fix typo * tests: add invalid name tests and add linter * fix: shutdown signal * chore: update readme for githooks * chore: formatting * test: add cron validation * fix: valid cron schedule for network strategy
1 parent 243bbf7 commit 833e312

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+7004
-5944
lines changed

.githooks/commit-msg

100644100755
File mode changed.

.githooks/pre-push

100644100755
File mode changed.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ config/**/*.json
2929

3030
# Ignore DS_Store files
3131
.DS_Store
32+
33+
# Ignore proptest regressions
34+
tests/**/*.proptest-regressions

Cargo.lock

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2021"
77
async-trait = "0.1"
88
base64 = "0.22"
99
chrono = "0.4"
10+
cron = "0.15.0"
1011
dotenvy = "0.15.7"
1112
email_address = "0.2.9"
1213
env_logger = "0.11.5"
@@ -28,5 +29,6 @@ tokio-cron-scheduler = "0.13.0"
2829
web3 = "0.19.0"
2930

3031
[dev-dependencies]
31-
tempfile = "3.2"
3232
mockall = "0.13.1"
33+
proptest = "1.6.0"
34+
tempfile = "3.2"

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,18 @@ cargo run
210210
### Run Tests
211211

212212
```bash
213-
cargo test -- --nocapture
213+
cargo test
214+
cargo test properties
215+
cargo test integration
214216
```
215217

218+
### Developer setup
219+
220+
1. Run `chmod +x .githooks/*` to make the git hooks executable.
221+
2. Run `git config core.hooksPath .githooks` to setup git hooks for linting and formatting.
222+
3. Run `rustup toolchain install nightly` to install the nightly toolchain.
223+
4. Run `rustup component add rustfmt --toolchain nightly` to install rustfmt for the nightly toolchain.
224+
216225
## Project Structure
217226

218227
- `src/`: Source code
@@ -227,8 +236,14 @@ cargo test -- --nocapture
227236
## Caveats
228237

229238
- This software is in alpha. Use in production environments at your own risk.
239+
- EVM monitors require an ABI to decode and trigger on contract events and functions.
230240
- Monitor performance depends on network congestion and RPC endpoint reliability.
231-
- Past block processing is limited by `max_past_blocks` in network configuration (default: 10).
241+
- The `max_past_blocks` configuration is critical to prevent missing blocks:
242+
- Should be approximately calculated as: `(cron_interval_ms/block_time_ms) + confirmation_blocks + 1` (defaults to this value if not set)
243+
- Example: For 1-minute cron on Ethereum (~12s blocks, 12 confirmation blocks):
244+
- `(60000/12000) + 12 + 1 = 18 blocks`
245+
- Setting this too low may result in missed blocks, especially on fast networks
246+
- Consider network congestion and block time variability when configuring
232247
- For email notifications, the `port` field is optional and defaults to 465.
233248
- Template variable availability depends on the trigger source:
234249
- If triggered by an event, only event variables will be populated.

config/networks/ethereum_mainnet.json.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"block_time_ms": 12000,
1414
"confirmation_blocks": 12,
1515
"cron_schedule": "0 */1 * * * *",
16-
"max_past_blocks": 3,
16+
"max_past_blocks": 18,
1717
"store_blocks": false
1818
}

config/networks/stellar_mainnet.json.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"block_time_ms": 5000,
1414
"confirmation_blocks": 2,
1515
"cron_schedule": "0 */1 * * * *",
16-
"max_past_blocks": 3,
16+
"max_past_blocks": 20,
1717
"store_blocks": true
1818
}

config/networks/stellar_testnet.json.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"block_time_ms": 5000,
1414
"confirmation_blocks": 2,
1515
"cron_schedule": "0 */1 * * * *",
16-
"max_past_blocks": 50,
16+
"max_past_blocks": 20,
1717
"store_blocks": true
1818
}

config/triggers/email_notifications.json.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"subject": "large_transfer_usdc_email triggered",
1111
"body": "Large transfer of ${event_0_value} USDC from ${event_0_from} to ${event_0_to} | https://etherscan.io/tx/${transaction_hash}#eventlog",
1212
"sender": "[email protected]",
13-
"receipients": [
13+
"recipients": [
1414
1515
1616
]
@@ -27,7 +27,7 @@
2727
"subject": "large_transfer_usdc_email triggered",
2828
"body": "${monitor_name} triggered because of a large transfer of ${function_0_2} USDC to ${function_0_1} | https://stellar.expert/explorer/testnet/tx/${transaction_hash}",
2929
"sender": "[email protected]",
30-
"receipients": [
30+
"recipients": [
3131
3232
3333
]

0 commit comments

Comments
 (0)