-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (115 loc) · 5.67 KB
/
allocation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Allocation tests
on:
push:
workflow_dispatch:
schedule:
- cron: "42 3 * * *"
jobs:
test_allocation:
name: Test Allocation
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "dev-build-cache"
- name: Build
run: |
cargo build
cp target/debug/erc20_processor /usr/local/bin/erc20_processor
[ $(which erc20_processor) == "/usr/local/bin/erc20_processor" ]
- name: Generate ethereum accounts
run: |
erc20_processor generate-key -n 5 > .env
cat .env | grep ETH_ADDRESS | sed "s/#\s//g" | sed "s/:\s/=/g" > $GITHUB_ENV
- name: Create random allocation id
run: |
echo ALLOCATION_ID0=$(shuf -i 0-2000000000 -n 1) >> $GITHUB_ENV
echo ALLOCATION_ID1=$(shuf -i 0-2000000000 -n 1) >> $GITHUB_ENV
echo ALLOCATION_ID2=$(shuf -i 0-2000000000 -n 1) >> $GITHUB_ENV
- name: Show created addresses
run: |
echo "Eth address 0: $ETH_ADDRESS_0"
echo "Eth address 1: $ETH_ADDRESS_1"
echo "Eth address 2: $ETH_ADDRESS_2"
echo "Eth address 3: $ETH_ADDRESS_3"
echo "Eth address 4: $ETH_ADDRESS_4"
- name: Get ETH from faucet for account 1 and 2
run: |
erc20_processor get-dev-eth --account-no 1
erc20_processor get-dev-eth --account-no 2
- name: Check ETH balance after getting funds from faucet (should be 0.01)
run: |
x=1; while [ $(erc20_processor balance | jq -r ".\"$ETH_ADDRESS_1\".gasDecimal") != "0.01" ]; do echo "Waiting for funds for $x seconds"; sleep 5; x=$(( x + 5 )); done
while [ $(erc20_processor balance | jq -r ".\"$ETH_ADDRESS_2\".gasDecimal") != "0.01" ]; do echo "Waiting for funds for $x seconds"; sleep 5; x=$(( x + 5 )); done
- name: Mint tokens
run: |
erc20_processor mint-test-tokens --account-no 1
erc20_processor run
- name: Check token balance
run: |
[ $(erc20_processor balance | jq -r ".\"$ETH_ADDRESS_1\".tokenDecimal") == "1000" ]
- name: Deposit 800.0 GLM tokens
run: |
erc20_processor deposit --account-no 1 --amount 800
erc20_processor run
erc20_processor balance
- name: Create allocation
run: |
set -x
erc20_processor make-allocation --account-no 1 --amount 1 --fee-amount 0.1 --block-for 0 --spender $ETH_ADDRESS_2 --allocation-id $ALLOCATION_ID0 --use-internal
erc20_processor make-allocation --account-no 1 --amount 1 --fee-amount 0.1 --block-for 1000 --spender $ETH_ADDRESS_2 --allocation-id $ALLOCATION_ID1 --use-internal
erc20_processor run
- name: Check token balance zero
run: |
set -x
erc20_processor check-allocation --allocation-id $ALLOCATION_ID0
erc20_processor check-allocation --allocation-id $ALLOCATION_ID1
- name: Make single transfer from allocation
run: |
set -x
erc20_processor transfer --allocation-id $ALLOCATION_ID0 --account-no 2 --amount 0.0001 --recipient $ETH_ADDRESS_4 --use-internal
erc20_processor run
- name: Make single transfer without allocation
run: |
set -x
erc20_processor transfer --account-no 1 --amount 0.0001 --recipient $ETH_ADDRESS_4 --use-internal
erc20_processor run
- name: Make multiple transfers from allocation
run: |
set -x
erc20_processor transfer --allocation-id $ALLOCATION_ID1 --account-no 2 --amount 0.0001 --recipient $ETH_ADDRESS_0 --use-internal
erc20_processor transfer --allocation-id $ALLOCATION_ID1 --account-no 2 --amount 0.0001 --recipient $ETH_ADDRESS_3 --use-internal
erc20_processor transfer --allocation-id $ALLOCATION_ID1 --account-no 2 --amount 0.0001 --recipient $ETH_ADDRESS_4 --use-internal
erc20_processor run
erc20_processor balance
- name: Make multiple transfer without allocation
run: |
set -x
erc20_processor transfer --account-no 1 --amount 0.0001 --recipient $ETH_ADDRESS_0 --use-internal
erc20_processor transfer --account-no 1 --amount 0.0001 --recipient $ETH_ADDRESS_3 --use-internal
erc20_processor transfer --account-no 1 --amount 0.0001 --recipient $ETH_ADDRESS_4 --use-internal
erc20_processor run
erc20_processor balance
- name: Free allocation
run: |
set -x
erc20_processor cancel-allocation --allocation-id $ALLOCATION_ID0 --account-no 1 --use-internal
erc20_processor cancel-allocation --allocation-id $ALLOCATION_ID1 --account-no 1 --use-internal || echo "Error expected (OK)"
erc20_processor cancel-allocation --allocation-id $ALLOCATION_ID1 --account-no 2 --use-internal || echo "Error expected (OK)"
erc20_processor run
- name: Withdraw all tokens
run: |
set -x
erc20_processor withdraw --account-no 1 --all
erc20_processor withdraw --account-no 2 --all
erc20_processor run
- name: Transfer all left ETH tokens
run: |
set -x
erc20_processor transfer --account-no 1 --recipient 0x5b984629E2Cc7570cBa7dD745b83c3dD23Ba6d0f --token eth --all
erc20_processor transfer --account-no 2 --recipient 0x5b984629E2Cc7570cBa7dD745b83c3dD23Ba6d0f --token eth --all
erc20_processor run