Skip to content

Commit

Permalink
chore!: require compiler 6 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Oct 27, 2021
1 parent ac805e8 commit f9cef12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/contract/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export default AsyncInit.compose(ContractBase, {
this.compilerVersion = client.spec.info.version
this._compilerApi = client.api

this._isCompiler6 = semverSatisfies(this.compilerVersion, COMPILER_6_GE_VERSION, COMPILER_LT_VERSION)
if (ignoreVersion) return
if (!semverSatisfies(this.compilerVersion, COMPILER_GE_VERSION, COMPILER_LT_VERSION)) {
throw new Error(`Unsupported compiler version ${this.compilerVersion}. ` +
Expand Down Expand Up @@ -170,6 +169,5 @@ export default AsyncInit.compose(ContractBase, {
}
})

const COMPILER_GE_VERSION = '4.1.0'
const COMPILER_6_GE_VERSION = '6.0.0'
const COMPILER_GE_VERSION = '6.0.0'
const COMPILER_LT_VERSION = '7.0.0'
16 changes: 8 additions & 8 deletions test/integration/contract-aci.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ const libContract = `
namespace TestLib =
function sum(x: int, y: int) : int = x + y
`
const genTestContract = isCompiler6 => `
const testContract = `
namespace Test =
function double(x: int): int = x*2
contract ${isCompiler6 ? 'interface' : ''} Voting =
contract interface Voting =
type test_type = int
record state = { value: string, key: test_type, testOption: option(string) }
record test_record = { value: string, key: list(test_type) }
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('Contract ACI Interface', function () {

before(async () => {
cInstance = await sdk.getContractInstance(
genTestContract(sdk._isCompiler6),
testContract,
{ filesystem }
)
await cInstance.deploy(['test', 1, 'some'])
Expand Down Expand Up @@ -171,7 +171,7 @@ describe('Contract ACI Interface', function () {

it('Generate ACI object', async () => {
contractObject = await sdk.getContractInstance(
genTestContract(sdk._isCompiler6),
testContract,
{ filesystem, ttl: 0 }
)
contractObject.should.have.property('interface')
Expand Down Expand Up @@ -225,7 +225,7 @@ describe('Contract ACI Interface', function () {
})
it('Generate ACI object with corresponding bytecode', async () => {
await sdk.getContractInstance(
genTestContract(sdk._isCompiler6),
testContract,
{ contractAddress: contractObject.deployInfo.address, filesystem, ttl: 0 }
)
})
Expand All @@ -248,7 +248,7 @@ describe('Contract ACI Interface', function () {
it('Throw error on creating contract instance with invalid contractAddress', async () => {
try {
await sdk.getContractInstance(
genTestContract(sdk._isCompiler6),
testContract,
{ filesystem, contractAddress: 'ct_asdasdasd', ttl: 0 }
)
} catch (e) {
Expand All @@ -259,7 +259,7 @@ describe('Contract ACI Interface', function () {
const contractAddress = 'ct_ptREMvyDbSh1d38t4WgYgac5oLsa2v9xwYFnG7eUWR8Er5cmT'
try {
await sdk.getContractInstance(
genTestContract(sdk._isCompiler6),
testContract,
{ filesystem, contractAddress, ttl: 0 }
)
} catch (e) {
Expand Down Expand Up @@ -631,7 +631,7 @@ describe('Contract ACI Interface', function () {
let cInstance
before(async () => {
cInstance = await sdk.getContractInstance(
genTestContract(sdk._isCompiler6),
testContract,
{ filesystem }
)
})
Expand Down

0 comments on commit f9cef12

Please sign in to comment.