Skip to content

Commit

Permalink
Merge branch 'master' into aaronmgdr/brandkit
Browse files Browse the repository at this point in the history
* master:
  Adjust e2e transfer and governance tests to match new fee distribution and eliminate ProposerFraction (#1585)
  [Wallet] Add more local currencies (#1698)
  Switch to correct cluster when fauceting (#1687)
  [Wallet] Use the country of the phone number for determining the default local currency (#1684)
  [Wallet] Limit QR code scanner to 1 code per second (#1676)
  Update Dark backgrounds text color (#1677)
  Remove integration sync test
  Minor attestation service fixes (#1680)
  Add golang to setup docs
  • Loading branch information
aaronmgdr committed Nov 14, 2019
2 parents 62077b3 + 413739b commit 3fd7a2f
Show file tree
Hide file tree
Showing 36 changed files with 699 additions and 565 deletions.
17 changes: 0 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -583,23 +583,6 @@ jobs:
cd packages/celotool
./ci_test_sync.sh checkout master
end-to-end-geth-integration-sync-test:
<<: *e2e-defaults
steps:
- attach_workspace:
at: ~/app
- run:
name: Check if the test should run
command: |
FILES_TO_CHECK="${PWD}/packages/celotool,${PWD}/packages/protocol,${PWD}/.circleci/config.yml"
./scripts/ci_check_if_test_should_run_v2.sh ${FILES_TO_CHECK}
- run:
name: Run test
command: |
set -e
cd packages/celotool
./ci_test_sync_with_network.sh checkout master
end-to-end-geth-attestations-test:
<<: *e2e-defaults
resource_class: medium+
Expand Down
18 changes: 18 additions & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [Installing OpenJDK 8](#installing-openjdk-8)
- [Install Android Dev Tools](#install-android-dev-tools-1)
- [Some common stuff](#some-common-stuff)
- [Install Go](#install-go)
- [Optional: Install Rust](#optional-install-rust)
- [Optional: Install an Android Emulator](#optional-install-an-android-emulator)
- [Optional: Genymotion](#optional-genymotion)
Expand Down Expand Up @@ -176,6 +177,23 @@ You can find the complete instructions about how to install the tools in Linux e

### Some common stuff

#### Install Go

We need Go for [celo-blockchain](https://github.com/celo-org/celo-blockchain), the Go Celo implementation, and `gobind` to build Java language bindings to Go code for the Android Geth client).

Note: We currently use Go 1.11. Brew installs Go 1.12 by default, which is not entirely compatible with our repositories. [Install Go 1.11 manually](https://golang.org/dl/), then run

```
go get golang.org/x/mobile/cmd/gobind
```

Execute the following (and make sure the lines are in your `~/.bash_profile`):

```
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
```

#### Optional: Install Rust

We use Rust to build the [bls-zexe](https://github.com/celo-org/bls-zexe) repo, which Geth depends on. If you only use the monorepo, you probably don't need this.
Expand Down
4 changes: 2 additions & 2 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# More details: https://github.com/GoogleContainerTools/kaniko

steps:

- id: "docker:celotool"
name: gcr.io/kaniko-project/executor:latest
args: [
Expand Down Expand Up @@ -37,7 +37,7 @@ steps:
args: [
"--dockerfile=dockerfiles/attestation-service/Dockerfile",
"--cache=true",
"--destination=gcr.io/$PROJECT_ID/celo-monorepo:attestation-service-$COMMIT_SHA"
"--destination=us.gcr.io/$PROJECT_ID/celo-monorepo:attestation-service-$COMMIT_SHA"
]
waitFor: ['-']

Expand Down
62 changes: 0 additions & 62 deletions packages/celotool/ci_test_sync_with_network.sh

This file was deleted.

51 changes: 0 additions & 51 deletions packages/celotool/geth_tests/network_sync_test.sh

This file was deleted.

3 changes: 3 additions & 0 deletions packages/celotool/src/cmds/account/faucet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* tslint:disable no-console */
import { newKit } from '@celo/contractkit'
import { switchToClusterFromEnv } from 'src/lib/cluster'
import { convertToContractDecimals } from 'src/lib/contract-utils'
import { portForwardAnd } from 'src/lib/port_forward'
import { validateAccountAddress } from 'src/lib/utils'
Expand Down Expand Up @@ -29,6 +30,8 @@ export const builder = (argv: yargs.Argv) => {
}

export const handler = async (argv: FaucetArgv) => {
await switchToClusterFromEnv()

const address = argv.account

const cb = async () => {
Expand Down
77 changes: 36 additions & 41 deletions packages/celotool/src/e2e-tests/governance_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@ describe('governance tests', () => {
return blockNumber % epochSize === 0
}

const assertBalanceChanged = async (
address: string,
blockNumber: number,
expected: BigNumber,
token: any
) => {
const currentBalance = new BigNumber(
await token.methods.balanceOf(address).call({}, blockNumber)
)
const previousBalance = new BigNumber(
await token.methods.balanceOf(address).call({}, blockNumber - 1)
)
assert.isNotNaN(currentBalance)
assert.isNotNaN(previousBalance)
assertAlmostEqual(currentBalance.minus(previousBalance), expected)
}

describe('when the validator set is changing', () => {
let epoch: number
const blockNumbers: number[] = []
Expand Down Expand Up @@ -302,24 +319,8 @@ describe('governance tests', () => {
)
const [group] = await validators.methods.getRegisteredValidatorGroups().call()

const assertBalanceChanged = async (
validator: string,
blockNumber: number,
expected: BigNumber
) => {
const currentBalance = new BigNumber(
await stableToken.methods.balanceOf(validator).call({}, blockNumber)
)
const previousBalance = new BigNumber(
await stableToken.methods.balanceOf(validator).call({}, blockNumber - 1)
)
assert.isNotNaN(currentBalance)
assert.isNotNaN(previousBalance)
assertAlmostEqual(currentBalance.minus(previousBalance), expected)
}

const assertBalanceUnchanged = async (validator: string, blockNumber: number) => {
await assertBalanceChanged(validator, blockNumber, new BigNumber(0))
await assertBalanceChanged(validator, blockNumber, new BigNumber(0), stableToken)
}

const getExpectedTotalPayment = async (validator: string, blockNumber: number) => {
Expand Down Expand Up @@ -359,17 +360,19 @@ describe('governance tests', () => {
await assertBalanceChanged(
validator,
blockNumber,
expectedTotalPayment.minus(groupPayment)
expectedTotalPayment.minus(groupPayment),
stableToken
)
expectedGroupPayment = expectedGroupPayment.plus(groupPayment)
}
await assertBalanceChanged(group, blockNumber, expectedGroupPayment)
await assertBalanceChanged(group, blockNumber, expectedGroupPayment, stableToken)
}
})

it('should distribute epoch rewards at the end of each epoch', async () => {
const lockedGold = await kit._web3Contracts.getLockedGold()
const governance = await kit._web3Contracts.getGovernance()
const gasPriceMinimum = await kit._web3Contracts.getGasPriceMinimum()
const [group] = await validators.methods.getRegisteredValidatorGroups().call()

const assertVotesChanged = async (blockNumber: number, expected: BigNumber) => {
Expand All @@ -382,6 +385,13 @@ describe('governance tests', () => {
assertAlmostEqual(currentVotes.minus(previousVotes), expected)
}

// Returns the gas fee base for a given block, which is distributed to the governance contract.
const blockBaseGasFee = async (blockNumber: number): Promise<BigNumber> => {
const gas = (await web3.eth.getBlock(blockNumber)).gasUsed
const gpm = await gasPriceMinimum.methods.gasPriceMinimum().call({}, blockNumber)
return new BigNumber(gpm).times(new BigNumber(gas))
}

const assertGoldTokenTotalSupplyChanged = async (
blockNumber: number,
expected: BigNumber
Expand All @@ -395,26 +405,12 @@ describe('governance tests', () => {
assertAlmostEqual(currentSupply.minus(previousSupply), expected)
}

const assertBalanceChanged = async (
address: string,
blockNumber: number,
expected: BigNumber
) => {
const currentBalance = new BigNumber(
await goldToken.methods.balanceOf(address).call({}, blockNumber)
)
const previousBalance = new BigNumber(
await goldToken.methods.balanceOf(address).call({}, blockNumber - 1)
)
assertAlmostEqual(currentBalance.minus(previousBalance), expected)
}

const assertLockedGoldBalanceChanged = async (blockNumber: number, expected: BigNumber) => {
await assertBalanceChanged(lockedGold.options.address, blockNumber, expected)
await assertBalanceChanged(lockedGold.options.address, blockNumber, expected, goldToken)
}

const assertGovernanceBalanceChanged = async (blockNumber: number, expected: BigNumber) => {
await assertBalanceChanged(governance.options.address, blockNumber, expected)
await assertBalanceChanged(governance.options.address, blockNumber, expected, goldToken)
}

const assertVotesUnchanged = async (blockNumber: number) => {
Expand All @@ -429,10 +425,6 @@ describe('governance tests', () => {
await assertLockedGoldBalanceChanged(blockNumber, new BigNumber(0))
}

const assertGovernanceBalanceUnchanged = async (blockNumber: number) => {
await assertGovernanceBalanceChanged(blockNumber, new BigNumber(0))
}

const getStableTokenSupplyChange = async (blockNumber: number) => {
const currentSupply = new BigNumber(
await stableToken.methods.totalSupply().call({}, blockNumber)
Expand Down Expand Up @@ -477,13 +469,16 @@ describe('governance tests', () => {
.plus(stableTokenSupplyChange.div(exchangeRate))
await assertVotesChanged(blockNumber, expectedEpochReward)
await assertLockedGoldBalanceChanged(blockNumber, expectedEpochReward)
await assertGovernanceBalanceChanged(blockNumber, expectedInfraReward)
await assertGovernanceBalanceChanged(
blockNumber,
expectedInfraReward.plus(await blockBaseGasFee(blockNumber))
)
await assertGoldTokenTotalSupplyChanged(blockNumber, expectedGoldTotalSupplyChange)
} else {
await assertVotesUnchanged(blockNumber)
await assertGoldTokenTotalSupplyUnchanged(blockNumber)
await assertLockedGoldBalanceUnchanged(blockNumber)
await assertGovernanceBalanceUnchanged(blockNumber)
await assertGovernanceBalanceChanged(blockNumber, await blockBaseGasFee(blockNumber))
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion packages/celotool/src/e2e-tests/sync_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('sync tests', function(this: any) {
const instance: GethInstanceConfig = gethConfig.instances[0]
await killInstance(instance)
await initAndStartGeth(hooks.gethBinaryPath, instance)
await sleep(60) // wait for round change / resync
await sleep(120) // wait for round change / resync
const address = (await web3.eth.getAccounts())[0]
const currentBlock = await web3.eth.getBlock('latest')
for (let i = 0; i < gethConfig.instances.length; i++) {
Expand Down
Loading

0 comments on commit 3fd7a2f

Please sign in to comment.