Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into init_start_suppor…
Browse files Browse the repository at this point in the history
…t_gatewayconfig
  • Loading branch information
gulshanvasnani committed Oct 23, 2019
2 parents f681282 + 26f404c commit a89317c
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 107 deletions.
3 changes: 3 additions & 0 deletions src/bin/facilitator-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ commander

Logger.info(`👉 worker address for ${auxChainId} chain is `
+ `${facilitatorConfig.chains[auxChainId].worker}`);
Logger.info(`\nℹ️ Run below two commands on terminal by replacing <origin password> and <auxiliary-password> with origin and auxiliary password entered in command. \n
1. export ${ENV_WORKER_PASSWORD_PREFIX + facilitatorConfig.chains[originChainId!].worker}=<origin-password>
2. export ${ENV_WORKER_PASSWORD_PREFIX + facilitatorConfig.chains[auxChainId].worker}=<auxiliary-password> \n\n`);
} catch (e) {
Logger.error(e);
process.exit(1);
Expand Down
16 changes: 8 additions & 8 deletions src/models/AuxiliaryChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export default class AuxiliaryChain extends Comparable<AuxiliaryChain> {

public originChainName: string;

public ostGatewayAddress: string;
public eip20GatewayAddress: string;

public ostCoGatewayAddress: string;
public eip20CoGatewayAddress: string;

public anchorAddress: string;

Expand All @@ -48,8 +48,8 @@ export default class AuxiliaryChain extends Comparable<AuxiliaryChain> {
*
* @param chainId Chain identifier.
* @param originChainName Name of the origin chain.
* @param ostGatewayAddress Gateway contract address.
* @param ostCoGatewayAddress CoGateway contract address.
* @param eip20GatewayAddress Gateway contract address.
* @param eip20CoGatewayAddress CoGateway contract address.
* @param anchorAddress Anchor contract address.
* @param coAnchorAddress CoAnchor contract address.
* @param lastOriginBlockHeight Latest origin chain block height.
Expand All @@ -60,8 +60,8 @@ export default class AuxiliaryChain extends Comparable<AuxiliaryChain> {
public constructor(
chainId: number,
originChainName: string,
ostGatewayAddress: string,
ostCoGatewayAddress: string,
eip20GatewayAddress: string,
eip20CoGatewayAddress: string,
anchorAddress: string,
coAnchorAddress: string,
lastOriginBlockHeight?: BigNumber,
Expand All @@ -72,8 +72,8 @@ export default class AuxiliaryChain extends Comparable<AuxiliaryChain> {
super();
this.chainId = chainId;
this.originChainName = originChainName;
this.ostGatewayAddress = ostGatewayAddress;
this.ostCoGatewayAddress = ostCoGatewayAddress;
this.eip20GatewayAddress = eip20GatewayAddress;
this.eip20CoGatewayAddress = eip20CoGatewayAddress;
this.anchorAddress = anchorAddress;
this.coAnchorAddress = coAnchorAddress;
this.lastOriginBlockHeight = lastOriginBlockHeight;
Expand Down
12 changes: 6 additions & 6 deletions src/repositories/AuxiliaryChainRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class AuxiliaryChainModel extends Model {

public readonly originChainName!: string;

public readonly ostGatewayAddress!: string;
public readonly eip20GatewayAddress!: string;

public readonly ostCoGatewayAddress!: string;
public readonly eip20CoGatewayAddress!: string;

public readonly anchorAddress!: string;

Expand Down Expand Up @@ -74,15 +74,15 @@ export default class AuxiliaryChainRepository extends Subject<AuxiliaryChain> {
len: [3, 50],
},
},
ostGatewayAddress: {
eip20GatewayAddress: {
type: DataTypes.STRING,
allowNull: false,
validate: {
isAlphanumeric: true,
len: [42, 42],
},
},
ostCoGatewayAddress: {
eip20CoGatewayAddress: {
type: DataTypes.STRING,
allowNull: false,
validate: {
Expand Down Expand Up @@ -214,8 +214,8 @@ export default class AuxiliaryChainRepository extends Subject<AuxiliaryChain> {
return new AuxiliaryChain(
auxiliaryChainModel.chainId,
auxiliaryChainModel.originChainName,
auxiliaryChainModel.ostGatewayAddress,
auxiliaryChainModel.ostCoGatewayAddress,
auxiliaryChainModel.eip20GatewayAddress,
auxiliaryChainModel.eip20CoGatewayAddress,
auxiliaryChainModel.anchorAddress,
auxiliaryChainModel.coAnchorAddress,
new BigNumber(auxiliaryChainModel.lastOriginBlockHeight),
Expand Down
2 changes: 1 addition & 1 deletion src/services/redeem_and_unstake/ProveCoGatewayService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default class ProveCoGatewayService extends Observer<AuxiliaryChain> {
/**
* This is a private method which uses mosaic.js to make proveGateway transaction.
*
* @param gatewayAddress ost gateway address in origin chain.
* @param gatewayAddress Gateway address in origin chain.
* @param lastOriginBlockHeight Block height at which latest state root is anchored.
* @param encodedAccountValue RPL encoded value of gateway account.
* @param serializedAccountProof RLP encoded value of account proof.
Expand Down
6 changes: 3 additions & 3 deletions src/services/stake_and_mint/ProveGatewayService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,22 @@ export default class ProveGatewayService extends Observer<AuxiliaryChain> {
/**
* This is a private method which uses mosaic.js to make proveGateway transaction.
*
* @param ostCoGatewayAddress ost co-gateway address.
* @param eip20CoGatewayAddress Gateway address in auxiliary chain.
* @param lastOriginBlockHeight Block height at which latest state root is anchored.
* @param encodedAccountValue RPL encoded value of gateway account.
* @param serializedAccountProof RLP encoded value of account proof.
*
* @return Return a promise that resolves to receipt.
*/
private async prove(
ostCoGatewayAddress: string,
eip20CoGatewayAddress: string,
lastOriginBlockHeight: BigNumber,
encodedAccountValue: string,
serializedAccountProof: string,
): Promise<string> {
const eip20CoGateway: EIP20CoGateway = interacts.getEIP20CoGateway(
this.auxiliaryWeb3,
ostCoGatewayAddress,
eip20CoGatewayAddress,
);

const transactionOptions = {
Expand Down
4 changes: 2 additions & 2 deletions test/SeedData/populateDb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('SeedData.populateDb()', (): void => {
/**
* Verifies data which was inserted for StakePool related events in contract_entities table.
*/
async function verifyOstComposerRelatedContractEntities(): Promise<void> {
async function verifyStakePoolRelatedContractEntities(): Promise<void> {
const contractEntity = new ContractEntity(
stakePoolAddress,
EntityType.StakeRequesteds,
Expand Down Expand Up @@ -251,7 +251,7 @@ describe('SeedData.populateDb()', (): void => {
* Verifies data which was inserted in contract_entities table.
*/
async function verifyDataInContractEntitiesTable(): Promise<void> {
await verifyOstComposerRelatedContractEntities();
await verifyStakePoolRelatedContractEntities();
await verifyRedeemPoolRelatedContractEntities();
await verifyGatewayRelatedContractEntities();
await verifyAuxiliaryAnchorRelatedContractEntities();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('RedeemIntentDeclaredHandler.persist()', (): void => {
);

afterEach((): void => {
sinon.restore();
sinon.restore();
});

it('should change message source state to declared if message does not exist',
Expand Down Expand Up @@ -115,13 +115,13 @@ describe('RedeemIntentDeclaredHandler.persist()', (): void => {
);
existingMessageWithUndeclaredStatus.sourceStatus = MessageStatus.Undeclared;

const mockedMessageRepository = sinon.createStubInstance(MessageRepository,
const mockedMessageRepository1 = sinon.createStubInstance(MessageRepository,
{
save: save as any,
get: Promise.resolve(existingMessageWithUndeclaredStatus),
});
const handler = new RedeemIntentDeclaredHandler(
mockedMessageRepository as any,
mockedMessageRepository1 as any,
mockedMessageTransferRequestRepository as any,
);

Expand All @@ -142,7 +142,7 @@ describe('RedeemIntentDeclaredHandler.persist()', (): void => {
);
SpyAssert.assert(save, 1, [[expectedModel]]);
SpyAssert.assert(
mockedMessageRepository.get,
mockedMessageRepository1.get,
1,
[[transactions[0]._messageHash]],
);
Expand Down Expand Up @@ -342,7 +342,7 @@ describe('RedeemIntentDeclaredHandler.persist()', (): void => {
expectedMessageModel.sourceStatus = MessageStatus.Declared;
expectedMessageModel.gatewayAddress = transactions[0].contractAddress;
expectedMessageModel.sourceDeclarationBlockHeight = new BigNumber(
transactions[0].blockNumber
transactions[0].blockNumber,
);

// Validate message models
Expand All @@ -364,36 +364,36 @@ describe('RedeemIntentDeclaredHandler.persist()', (): void => {
SpyAssert.assert(redeemRequestSave, 1, [[redeemRequest]]);
});

it('should not update messageHash in messageTransferRequestRepository when redeemRequest is' +
' undefined',
async (): Promise<void> => {
const messageSave = sinon.stub();
const mockedMessageRepository = sinon.createStubInstance(MessageRepository,
{
save: messageSave as any,
get: Promise.resolve(null),
});
it('should not update messageHash in messageTransferRequestRepository when redeemRequest is'
+ ' undefined',
async (): Promise<void> => {
const messageSave = sinon.stub();
const mockedMessageRepository = sinon.createStubInstance(MessageRepository,
{
save: messageSave as any,
get: Promise.resolve(null),
});

const redeemRequestSave = sinon.stub();
mockedMessageTransferRequestRepository = sinon.createStubInstance(
MessageTransferRequestRepository,
{
getBySenderProxyNonce: Promise.resolve(null),
save: redeemRequestSave as any,
},
);
const redeemRequestSave = sinon.stub();
mockedMessageTransferRequestRepository = sinon.createStubInstance(
MessageTransferRequestRepository,
{
getBySenderProxyNonce: Promise.resolve(null),
save: redeemRequestSave as any,
},
);

const handler = new RedeemIntentDeclaredHandler(
mockedMessageRepository as any,
mockedMessageTransferRequestRepository as any,
);
await handler.persist(transactions);
const handler = new RedeemIntentDeclaredHandler(
mockedMessageRepository as any,
mockedMessageTransferRequestRepository as any,
);
await handler.persist(transactions);

SpyAssert.assert(
mockedMessageTransferRequestRepository.getBySenderProxyNonce,
1,
[[transactions[0]._redeemer, new BigNumber(transactions[0]._redeemerNonce)]],
);
SpyAssert.assert(redeemRequestSave, 0, [[]]);
});
SpyAssert.assert(
mockedMessageTransferRequestRepository.getBySenderProxyNonce,
1,
[[transactions[0]._redeemer, new BigNumber(transactions[0]._redeemerNonce)]],
);
SpyAssert.assert(redeemRequestSave, 0, [[]]);
});
});
8 changes: 4 additions & 4 deletions test/repositories/AuxiliaryChainRepository/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ describe('AuxiliaryChain::get', (): void => {
};
const chainId = 2;
const originChainName = 'ropsten';
const ostGatewayAddress = '0x0000000000000000000000000000000000000001';
const ostCoGatewayAddress = '0x0000000000000000000000000000000000000002';
const eip20GatewayAddress = '0x0000000000000000000000000000000000000001';
const eip20CoGatewayAddress = '0x0000000000000000000000000000000000000002';
const anchorAddress = '0x0000000000000000000000000000000000000003';
const coAnchorAddress = '0x0000000000000000000000000000000000000004';
const lastOriginBlockHeight = new BigNumber('200');
Expand All @@ -49,8 +49,8 @@ describe('AuxiliaryChain::get', (): void => {
auxiliaryChain = new AuxiliaryChain(
chainId,
originChainName,
ostGatewayAddress,
ostCoGatewayAddress,
eip20GatewayAddress,
eip20CoGatewayAddress,
anchorAddress,
coAnchorAddress,
lastOriginBlockHeight,
Expand Down
32 changes: 16 additions & 16 deletions test/repositories/AuxiliaryChainRepository/save.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ let config: TestConfigInterface;
describe('AuxiliaryChainRepository::save', (): void => {
let chainId: number;
let originChainName: string;
let ostGatewayAddress: string;
let ostCoGatewayAddress: string;
let eip20GatewayAddress: string;
let eip20CoGatewayAddress: string;
let anchorAddress: string;
let coAnchorAddress: string;
let lastOriginBlockHeight: BigNumber;
Expand All @@ -46,8 +46,8 @@ describe('AuxiliaryChainRepository::save', (): void => {
};
chainId = 2;
originChainName = 'ropsten';
ostGatewayAddress = '0x0000000000000000000000000000000000000001';
ostCoGatewayAddress = '0x0000000000000000000000000000000000000002';
eip20GatewayAddress = '0x0000000000000000000000000000000000000001';
eip20CoGatewayAddress = '0x0000000000000000000000000000000000000002';
anchorAddress = '0x0000000000000000000000000000000000000003';
coAnchorAddress = '0x0000000000000000000000000000000000000004';
lastOriginBlockHeight = new BigNumber('200');
Expand All @@ -60,8 +60,8 @@ describe('AuxiliaryChainRepository::save', (): void => {
const auxiliaryChain = new AuxiliaryChain(
chainId,
originChainName,
ostGatewayAddress,
ostCoGatewayAddress,
eip20GatewayAddress,
eip20CoGatewayAddress,
anchorAddress,
coAnchorAddress,
lastOriginBlockHeight,
Expand All @@ -80,8 +80,8 @@ describe('AuxiliaryChainRepository::save', (): void => {
const auxiliaryChain = new AuxiliaryChain(
chainId,
originChainName,
ostGatewayAddress,
ostCoGatewayAddress,
eip20GatewayAddress,
eip20CoGatewayAddress,
anchorAddress,
coAnchorAddress,
lastOriginBlockHeight,
Expand All @@ -102,12 +102,12 @@ describe('AuxiliaryChainRepository::save', (): void => {
Util.assertAuxiliaryChainAttributes(updatedAuxiliaryChain, auxiliaryChain);
});

it('should fail when ostGatewayAddress is null', async (): Promise<void> => {
it('should fail when eip20GatewayAddress is null', async (): Promise<void> => {
const auxiliaryChain = new AuxiliaryChain(
chainId,
originChainName,
null as any,
ostCoGatewayAddress,
eip20CoGatewayAddress,
anchorAddress,
coAnchorAddress,
lastOriginBlockHeight,
Expand All @@ -119,15 +119,15 @@ describe('AuxiliaryChainRepository::save', (): void => {
assert.isRejected(config.repos.auxiliaryChainRepository.save(
auxiliaryChain,
),
'AuxiliaryChain.ostGatewayAddress cannot be null');
'AuxiliaryChain.eip20GatewayAddress cannot be null');
});

it('should fail when ostGatewayAddress is undefined', async (): Promise<void> => {
it('should fail when eip20GatewayAddress is undefined', async (): Promise<void> => {
const auxiliaryChain = new AuxiliaryChain(
chainId,
originChainName,
undefined as any,
ostCoGatewayAddress,
eip20CoGatewayAddress,
anchorAddress,
coAnchorAddress,
lastOriginBlockHeight,
Expand All @@ -140,7 +140,7 @@ describe('AuxiliaryChainRepository::save', (): void => {
config.repos.auxiliaryChainRepository.save(
auxiliaryChain,
),
'AuxiliaryChain.ostGatewayAddress cannot be null',
'AuxiliaryChain.eip20GatewayAddress cannot be null',
);
});

Expand Down Expand Up @@ -172,8 +172,8 @@ describe('AuxiliaryChainRepository::save', (): void => {
} catch (error) {
assertErrorMessages(error.errors, [
'AuxiliaryChain.originChainName cannot be null',
'Validation len on ostGatewayAddress failed',
'Validation len on ostCoGatewayAddress failed',
'Validation len on eip20GatewayAddress failed',
'Validation len on eip20CoGatewayAddress failed',
'Validation len on anchorAddress failed',
'Validation len on coAnchorAddress failed',
]);
Expand Down
12 changes: 6 additions & 6 deletions test/repositories/AuxiliaryChainRepository/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ const Util = {
);

assert.strictEqual(
inputAuxiliaryChain.ostGatewayAddress,
expectedAuxiliaryChain.ostGatewayAddress,
'ostGatewayAddress should match',
inputAuxiliaryChain.eip20GatewayAddress,
expectedAuxiliaryChain.eip20GatewayAddress,
'eip20GatewayAddress should match',
);

assert.strictEqual(
inputAuxiliaryChain.ostCoGatewayAddress,
expectedAuxiliaryChain.ostCoGatewayAddress,
'ostCoGatewayAddress should match',
inputAuxiliaryChain.eip20CoGatewayAddress,
expectedAuxiliaryChain.eip20CoGatewayAddress,
'eip20CoGatewayAddress should match',
);

assert.strictEqual(
Expand Down
Loading

0 comments on commit a89317c

Please sign in to comment.