Skip to content

Commit

Permalink
Merge pull request #323 from systemaccounting/322-rust-integration-tests
Browse files Browse the repository at this point in the history
322 rewrite node.js integration tests in rust
  • Loading branch information
mxfactorial authored Jan 30, 2024
2 parents 87a16a6 + bde8c80 commit 7da28b3
Show file tree
Hide file tree
Showing 47 changed files with 1,718 additions and 10,078 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/dev-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: start services
run: make start
- name: test service integration
run: make -C ./test test-local
run: make -C ./tests test-local
- name: reset db
run: make reset-db
- name: e2e test client
Expand All @@ -53,5 +53,11 @@ jobs:
run: cargo install cross --git https://github.com/cross-rs/cross
- name: deploy to cloud
run: bash scripts/deploy-all.sh --env dev --transaction-services-only
- name: cloud integration tests
run: make -C ./test test-cloud ENV=dev
- name: reset rds database for integration tests
run: make --no-print-directory -C ./migrations resetrds ENV=dev DB=test
- name: dump rds database locally for restore between integration tests
run: make --no-print-directory -C ./migrations/dumps dump-rds-testseed
- name: get secrets for dev integration tests
run: make --no-print-directory -C ./tests get-secrets ENV=dev
- name: run dev cloud integration tests
run: cargo test --manifest-path ./tests/Cargo.toml --features integration_tests -- --test-threads=1
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"editor.defaultFormatter": "svelte.svelte-vscode"
},
"thunder-client.saveToWorkspace": true,
"thunder-client.workspaceRelativePath": "test",
"thunder-client.workspaceRelativePath": "tests",
"sqltools.connections": [
{
"name": "mxfactorial-docker",
Expand Down
136 changes: 131 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"crates/sqls",
"crates/pg",
"crates/httpclient",
"tests",
]

[workspace.package]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ encryption and replication are secondary
**a.** money is accounting. when someone has a 5 in their pocket, it's because they had a credit of 5 and someone else had a debit of 5

**q.** what does physics have to do with accounting?
**a.** recording transactions between users as debit-credit pairs enforces a conservation law on value. since *macroaccounting* requires economic resources to be described as *conserved*, and not just "scarce", individuals stay clear of the many [schools of thought](https://en.wikipedia.org/wiki/Schools_of_economic_thought) indulged by the convenient handwaving of "macroeconomics". treating *'how to define and optimize the flow of goods and services?'* as a problem for physics & data science separates away the "social" from the *science*, and removes the academic community from serving as a source of confusion, instability and justification for government failure
**a.** recording transactions between users as debit-credit pairs enforces a conservation law on value. locking down the *'how to define and optimize the flow of goods and services?'* answer to a language that merges mathematical physics with computer science separates away the social from the science, and removes [high risk](https://en.wikipedia.org/wiki/Student_loan_default_in_the_United_States) academia from serving as a source of confusion, instability and justification for government failure. with macro**accounting** requiring economic resources to be described as *conserved*—and not just "scarce"—individuals stay clear of the many [schools of thought](https://en.wikipedia.org/wiki/Schools_of_economic_thought) indulged by the convenient handwaving of macroeconomics

**q.** what is the equation?
**a.** *u* = transactions per second, *w<sub>i</sub>* = value conserved per transaction, *Mx!* = value visible in a combinatorial game
Expand Down
3 changes: 2 additions & 1 deletion client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
"strict": true,
"ignoreDeprecations": "5.0"
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
Expand Down
46 changes: 44 additions & 2 deletions crates/types/src/request_response.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,50 @@
use crate::transaction;
use crate::{
account_role::AccountRole,
transaction::{Transaction, Transactions},
};
use serde::{Deserialize, Serialize};

#[derive(Eq, PartialEq, Debug, Deserialize, Serialize)]
pub struct IntraTransaction {
pub auth_account: Option<String>,
pub transaction: transaction::Transaction,
pub transaction: Transaction,
}

impl IntraTransaction {
pub fn new(auth_account: String, transaction: Transaction) -> Self {
Self {
auth_account: Some(auth_account),
transaction,
}
}
}

#[derive(Eq, PartialEq, Debug, Deserialize, Serialize)]
pub struct IntraTransactions {
pub auth_account: Option<String>,
pub transactions: Transactions,
}

#[derive(Eq, PartialEq, Debug, Deserialize, Serialize)]
pub struct RequestApprove {
auth_account: String,
id: String,
account_name: String,
account_role: AccountRole,
}

impl RequestApprove {
pub fn new(
auth_account: String,
transaction_id: String,
account_name: String,
account_role: AccountRole,
) -> Self {
Self {
auth_account,
id: transaction_id,
account_name,
account_role,
}
}
}
18 changes: 17 additions & 1 deletion crates/types/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ pub struct Transaction {
pub transaction_items: TransactionItems,
}

impl Transaction {
pub fn new(author: String, transaction_items: TransactionItems) -> Self {
Self {
id: None,
rule_instance_id: None,
author: Some(author),
author_device_id: None,
author_device_latlng: None,
author_role: None,
equilibrium_time: None,
sum_value: "0.000".to_string(), // used in integration tests for now
transaction_items,
}
}
}

#[cfg(test)]
pub mod tests {

Expand Down Expand Up @@ -732,5 +748,5 @@ pub mod tests {
}
}

#[derive(Eq, PartialEq, Debug, Deserialize)]
#[derive(Eq, PartialEq, Debug, Deserialize, Serialize)]
pub struct Transactions(pub Vec<Transaction>);
10 changes: 5 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ test:
$(MAKE) test-local

test-compose-up:
@$(MAKE) -C './test' test-compose-up
@$(MAKE) -C './tests' test-compose-up

test-docker:
@$(MAKE) -C './test' test-docker
@$(MAKE) -C './tests' test-docker

test-cloud:
@$(MAKE) -C './test' test-cloud
@$(MAKE) -C './tests' test-cloud

test-local:
@$(MAKE) -C './test' test-local
@$(MAKE) -C './tests' test-local

rust-coverage:
ifndef RUST_PKG
Expand Down Expand Up @@ -151,7 +151,7 @@ clean:
for d in "$${APP_DIRS[@]}"; do \
$(MAKE) --no-print-directory -C "$$d" clean; \
done
@$(MAKE) --no-print-directory -C test clean
@$(MAKE) --no-print-directory -C tests clean
@rm -f ./$(NOHUP_LOG)

###################### docker ######################
Expand Down
Loading

0 comments on commit 7da28b3

Please sign in to comment.