Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/requests test #34

Merged
merged 25 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fc02da8
Add inverted filter by event type
violog Jun 18, 2024
64f7c68
Add inverted filter also for public event types
violog Jun 18, 2024
5cca713
Add auxiliary test functions
Zaptoss Jun 18, 2024
cffb028
Reduce boilerplate code in testing request functions
violog Jun 18, 2024
35180cc
Fix auth in create balance. Fix points and level accruing after claim.
Zaptoss Jun 18, 2024
812c85f
Refactor balance creation architecture
violog Jun 18, 2024
7e83574
Add AutoClaim test. Refactoring
Zaptoss Jun 18, 2024
f86096e
Merge remote-tracking branch 'origin/fix/Artem/requests_test' into fi…
Zaptoss Jun 19, 2024
ef54d5f
Refactor test for levels logic
violog Jun 19, 2024
0d12492
Claim tests refactoring
Zaptoss Jun 19, 2024
def6c9c
Add testing config, check for balances and genesis code on setup
violog Jun 19, 2024
31501b3
Now init level for balance it is 0. Fix bug with adding fulfilled eve…
Zaptoss Jun 19, 2024
e8e65fb
fix genesis balance creation
Zaptoss Jun 19, 2024
6450538
Merge remote-tracking branch 'origin/fix/Artem/requests_test' into fi…
Zaptoss Jun 20, 2024
b8b539b
Fix bag with level accruing, because map can be indexed by for in dif…
Zaptoss Jun 20, 2024
1bb517f
Tests fix & refactoring
Zaptoss Jun 20, 2024
7b42bd6
Country pools tests
Zaptoss Jun 20, 2024
d002007
Referral status tests
Zaptoss Jun 20, 2024
e5ec3f2
Add withdraw tests
Zaptoss Jun 20, 2024
637e4ec
Config for tests
Zaptoss Jun 20, 2024
12b0056
Conflic resolving: Merge remote-tracking branch 'origin/main' into fi…
Zaptoss Jun 20, 2024
58b6046
Fix docs
Zaptoss Jun 20, 2024
8eaf8ae
Comments refactoring
Zaptoss Jun 20, 2024
39e0e47
Errorhandling, tests refactoring
Zaptoss Jun 20, 2024
5a4d083
Remove unnecessary code
Zaptoss Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,18 @@ and in handlers/verify_passport:
// return nil, problems.BadRequest(err)
// }
```
and in handlers/withdraw(lines 49-58):
```go
// validated in requests.NewWithdraw
// addr, _ := cosmos.AccAddressFromBech32(req.Data.Attributes.Address)
// never panics because of request validation
// proof.PubSignals[zk.Nullifier] = mustHexToInt(nullifier)

// err = Verifier(r).VerifyProof(proof, zk.WithEventData(addr))
// if err != nil {
// ape.RenderErr(w, problems.BadRequest(err)...)
// return
// }
```

Run service with standart config (you need to configure db url only) and run tests.
Run service with config-testing.yaml (you need to configure db url) and run tests.
139 changes: 139 additions & 0 deletions config-testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
log:
level: debug
disable_sentry: true

db:
url: postgres://points:points@localhost:5432/points?sslmode=disable

listener:
addr: localhost:8000

event_types:
types:
- name: free_weekly
reward: 1
frequency: weekly
title: Free weekly points
short_description: Get free points every week, just pressing the button
description: "## Free Weekly Points\n\nThis is a weekly event where users can earn free points.\n\n### How it works\n\n- Users are eligible to participate once every week.\n- Upon participation, users will receive 100 points.\n- These points can be used for various features in the application.\n\nParticipate every week and maximize your rewards!\n"
logo: https://pbs.twimg.com/profile_images/1639021161257263105/XmT0EBnK_400x400.jpg
starts_at: 2024-03-23T12:42:00Z
- name: passport_scan
reward: 5
frequency: one-time
title: Passport verification
short_description: Scan your passport to unlock features and get points
description: "## Passport verification\n\nThis is a general event description.\n\n### How it works\n\n- Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n- Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n\nParticipate every week and maximize your rewards!\n"
logo: https://pbs.twimg.com/profile_images/1639021161257263105/XmT0EBnK_400x400.jpg
starts_at: 2024-03-23T12:42:00Z
auto_claim: true
- name: referral_common
reward: 15
frequency: one-time
title: Refer new users
short_description: Refer friends and get a reward for each friend who verifies the passport
description: "## Referral program\n\nThis is a general event description.\n\n### How it works\n\n- Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n- Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n\nParticipate every week and maximize your rewards!\n"
action_url: https://rarimo.com
- name: referral_specific
reward: 1
frequency: unlimited
no_auto_open: true
title: Refer user <did>
short_description: The user <did> has verified the passport. Claim the reward!
description: "## Referral program\n\nThis is a general event description.\n\n### How it works\n\n- Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n- Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n\nParticipate every week and maximize your rewards!\n"
action_url: https://rarimo.com
auto_claim: true
- name: new_limited_event
title: Limited event
reward: 5
frequency: one-time
short_description: This event will expire soon
description: "## Limited event\n\nThis is a general event description.\n\n### How it works\n\n- Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n- Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n\nParticipate every week and maximize your rewards!\n"
action_url: https://rarimo.com
expires_at: 2024-11-01T00:00:00Z
- name: new_expired_event
title: Expired event
reward: 3
frequency: one-time
short_description: This event has expired
description: "## Expired event\n\nThis is a general event description.\n\n### How it works\n\n- Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n- Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n\nParticipate every week and maximize your rewards!\n"
action_url: https://rarimo.com
expires_at: 2024-06-10T00:00:00Z

levels:
levels:
- lvl: 1
threshold: 0
referrals: 5
withdrawal_allowed: false
- lvl: 2
threshold: 5
referrals: 5
withdrawal_allowed: true
- lvl: 3
threshold: 6
referrals: 5
withdrawal_allowed: true

countries:
countries:
- code: "UKR"
reserve_limit: 100000
reserve_allowed: true
withdrawal_allowed: true
- code: "USA"
reserve_limit: 100
reserve_allowed: false
withdrawal_allowed: false
- code: "GBR"
reserve_limit: 5
reserve_allowed: false
withdrawal_allowed: true
- code: "CAN"
reserve_limit: 5
reserve_allowed: true
withdrawal_allowed: true
- code: "FRA"
reserve_limit: 6
reserve_allowed: true
withdrawal_allowed: true
- code: "IND"
reserve_limit: 1
reserve_allowed: false
withdrawal_allowed: true
- code: "MCO"
reserve_limit: 100
reserve_allowed: false
withdrawal_allowed: false
- code: "BEL"
reserve_limit: 100
reserve_allowed: true
withdrawal_allowed: false
- code: "MNG"
reserve_limit: 100
reserve_allowed: false
withdrawal_allowed: true
- code: "default"
reserve_limit: 5
reserve_allowed: true
withdrawal_allowed: true

auth:
addr: http://localhost:9030

broadcaster:
addr: localhost:9010
sender_account: "rarimo1ghcxdrgmy8duq8cu68fgmlp2sfmfwkh2dl4chl"

verifier:
verification_key_path: "./verification_key.json"
allowed_age: 18
allowed_identity_timestamp: 1715698750

root_verifier:
rpc: https://your-rpc
contract: 0x7DdAde70efADf832A600ba483FAD26fCA477FE2A
request_timeout: 10s

withdrawal:
point_price_urmo: 1000000 # 1 RMO
12 changes: 5 additions & 7 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ event_types:
frequency: one-time
action_url: https://...
logo: https://...
auto_claim: true
- name: free_weekly
title: Free weekly points
reward: 1
Expand All @@ -44,6 +45,7 @@ event_types:
description: The user {:did} has verified the passport. Claim the reward!
short_description: Short description
no_auto_open: true
auto_claim: true

levels:
levels:
Expand All @@ -68,15 +70,11 @@ countries:
reserve_allowed: true
withdrawal_allowed: true
- code: "USA"
reserve_limit: 5
reserve_allowed: true
withdrawal_allowed: true
- code: "GBR"
reserve_limit: 5
reserve_limit: 0
reserve_allowed: false
withdrawal_allowed: true
withdrawal_allowed: false
- code: "default"
reserve_limit: 5
reserve_limit: 100
reserve_allowed: true
withdrawal_allowed: true

Expand Down
Loading
Loading