Skip to content

Commit

Permalink
refactor: rename forceCompatibility to more clear ignoreVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Apr 28, 2021
1 parent 2f90a96 commit 72f1d32
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ before_install:
- if [[ $TRAVIS_EVENT_TYPE == "cron" ]]; then
export NODE_TAG=master;
export COMPILER_TAG=latest;
export FORCE_COMPATIBILITY=true;
export IGNORE_VERSION=true;
fi
- if [[ $TRAVIS_BUILD_STAGE_NAME == "Integration tests" ]]; then
docker-compose up -d;
Expand Down
12 changes: 6 additions & 6 deletions src/contract/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ async function getBytecodeCompilerVersion (bytecode, options = {}) {
return this.http.post('/compiler-version', { bytecode, options: this.prepareCompilerOption(options) }, options)
}

async function setCompilerUrl (url, { forceCompatibility = false } = {}) {
async function setCompilerUrl (url, { ignoreVersion = false } = {}) {
this.http.changeBaseUrl(url)
this.compilerVersion = await this.getCompilerVersion().catch(e => null)
await this.checkCompatibility({ forceCompatibility })
await this.checkCompatibility({ ignoreVersion })
}

async function checkCompatibility ({ force = false, forceCompatibility = false } = {}) {
async function checkCompatibility ({ force = false, ignoreVersion = false } = {}) {
if (!this.compilerVersion && !force) throw new Error('Compiler do not respond')
if (!forceCompatibility && this.compilerVersion && !semverSatisfies(this.compilerVersion, COMPILER_GE_VERSION, COMPILER_LT_VERSION)) {
if (!ignoreVersion && this.compilerVersion && !semverSatisfies(this.compilerVersion, COMPILER_GE_VERSION, COMPILER_LT_VERSION)) {
const version = this.compilerVersion
this.compilerVersion = null
throw new Error(`Unsupported compiler version ${version}. ` +
Expand Down Expand Up @@ -134,10 +134,10 @@ function isInit () {
* @example ContractCompilerAPI({ compilerUrl: 'COMPILER_URL' })
*/
const ContractCompilerAPI = AsyncInit.compose(ContractBase, {
async init ({ compilerUrl = this.compilerUrl, forceCompatibility = false }) {
async init ({ compilerUrl = this.compilerUrl, ignoreVersion = false }) {
this.http = Http({ baseUrl: compilerUrl })
this.compilerVersion = await this.getCompilerVersion().catch(e => null)
await this.checkCompatibility({ force: true, forceCompatibility })
await this.checkCompatibility({ force: true, ignoreVersion })
},
methods: {
contractEncodeCallDataAPI,
Expand Down
4 changes: 2 additions & 2 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ const Node = AsyncInit.compose({
nodeNetworkId: null
}
}, {
async init ({ forceCompatibility = false }) {
async init ({ ignoreVersion = false }) {
const { nodeRevision: revision, genesisKeyBlockHash: genesisHash, networkId, protocols } = await this.api.getStatus()
this.consensusProtocolVersion = await this.getConsensusProtocolVersion(protocols)
if (
!semverSatisfies(this.version, NODE_GE_VERSION, NODE_LT_VERSION) &&
!forceCompatibility
!ignoreVersion
) {
throw new Error(
`Unsupported node version ${this.version}. ` +
Expand Down
4 changes: 2 additions & 2 deletions test/integration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const compilerUrl = process.env.COMPILER_URL || 'http://localhost:3080'
export const publicKey = process.env.PUBLIC_KEY || 'ak_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR'
const secretKey = process.env.SECRET_KEY || 'bf66e1c256931870908a649572ed0257876bb84e3cdf71efb12f56c7335fad54d5cf08400e988222f26eb4b02c8f89077457467211a6e6d955edb70749c6a33b'
export const networkId = process.env.TEST_NETWORK_ID || 'ae_devnet'
const forceCompatibility = process.env.FORCE_COMPATIBILITY || false
const ignoreVersion = process.env.IGNORE_VERSION || false
export const genesisAccount = MemoryAccount({ keypair: { publicKey, secretKey } })
export const account = Crypto.generateKeyPair()

Expand All @@ -38,7 +38,7 @@ export const BaseAe = async (params = {}) => {
props: { process, compilerUrl }
})({
...params,
forceCompatibility,
ignoreVersion,
accounts: [...params.accounts || [], genesisAccount],
nodes: [{ name: 'test', instance: await Node({ url, internalUrl }) }]
})
Expand Down

0 comments on commit 72f1d32

Please sign in to comment.