Skip to content

Commit 036a8a0

Browse files
committed
[CHANGE] Remove test key from repository
1 parent 962f26d commit 036a8a0

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

.github/workflows/CI.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ jobs:
1414
macos:
1515
needs: lint
1616
runs-on: macos-latest
17+
env:
18+
TESTS_PRIVATEKEY: ${{ secrets.TESTS_PRIVATEKEY }}
1719
steps:
1820
- uses: actions/checkout@v3
21+
- name: SetupKey
22+
run: ./scripts/setupKey.sh "${{ secrets.TESTS_PRIVATEKEY }}"
1923
- name: Build
2024
run: swift build -v
2125
- name: Tests
@@ -25,8 +29,12 @@ jobs:
2529
runs-on: ubuntu-latest
2630
container:
2731
image: swift:5.5-bionic
32+
env:
33+
TESTS_PRIVATEKEY: ${{ secrets.TESTS_PRIVATEKEY }}
2834
steps:
2935
- uses: actions/checkout@v3
36+
- name: SetupKey
37+
run: ./scripts/setupKey.sh "${{ secrets.TESTS_PRIVATEKEY }}"
3038
- name: Build
3139
run: swift build -v
3240
- name: Tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ fastlane/screenshots
6666
fastlane/test_output
6767

6868
scripts/bin/*
69+
TestConfig_private.swift

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ We support querying ERC721 token data via the `ERC721` struct. Including:
159159

160160
### Running Tests
161161

162-
The tests will all pass when running against Goerli. You will need to provide a URL for the blockchain proxy (e.g. on Infura), and a key-pair in `TestConfig.swift`. Some of the account signing tests will fail, given the signature assertions are against a specific (unprovided) key.
162+
Some of the tests require a private key, which is not stored in the repository. You can ignore these while testing locally, as CI will use the encrypted secret key from Github.
163+
164+
It's better to run only the tests you need, instead of the whole test suite while developing. If you ever need to set up the key locally, take a look at `TestConfig.swift` where you can manually set it up. Alternatively you can set it up by calling the script `setupKey.sh` and passing the value (adding 0x) so it's written to an ignored file.
163165

164166
## Dependencies
165167

scripts/setupKey.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
# write first argument to a Test
4+
echo "extension TestConfig {\nstatic let privateKey = \"$1\"\n}" > web3sTests/TestConfig_private.swift

web3sTests/TestConfig.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ struct TestConfig {
1313
// This is the proxy wss URL for connecting to the Blockchain. For testing we usually use the Goerli network on Infura. Using free tier, so might hit rate limits
1414
static let wssUrl = "wss://goerli.infura.io/ws/v3/b2f4b3f635d8425c96854c3d28ba6bb0"
1515

16-
// An EOA with some Ether, so that we can test sending transactions (pay for gas)
17-
static let privateKey = "0xef4e182ae2cf32192d2a62c1159c8c4f7f2d658c303d0dfca5791a205456a132"
16+
// An EOA with some Ether, so that we can test sending transactions (pay for gas). Set by CI
17+
// static let privateKey = "SET_YOUR_KEY_HERE"
1818

1919
// This is the expected public key (address) from the above private key
20-
static let publicKey = "0x719561fee351F7aC6560D0302aE415FfBEEc0B51"
20+
static let publicKey = "0xE78e5ecb061fE3DD1672dDDA7b5116213B23B99A"
2121

2222
// A test ERC20 token contract (UNI)
2323
static let erc20Contract = "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"

0 commit comments

Comments
 (0)