Create _setCurrentContextAddressIfRequired function in MixinTransactions

This commit is contained in:
Amir Bandeali
2019-09-01 18:31:46 -07:00
parent 8231e7703e
commit d131c39e46
3 changed files with 35 additions and 7 deletions

View File

@@ -692,6 +692,22 @@ blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDef
});
});
describe('setCurrentContextAddressIfRequired', () => {
it('should set the currentContextAddress if not equal to sender', async () => {
const randomAddress = hexRandom(20);
await transactionsContract.setCurrentContextAddressIfRequired.awaitTransactionSuccessAsync(randomAddress);
const currentContextAddress = await transactionsContract.currentContextAddress.callAsync();
expect(currentContextAddress).to.eq(randomAddress);
});
it('should not set the currentContextAddress if equal to sender', async () => {
await transactionsContract.setCurrentContextAddressIfRequired.awaitTransactionSuccessAsync(accounts[0], {
from: accounts[0],
});
const currentContextAddress = await transactionsContract.currentContextAddress.callAsync();
expect(currentContextAddress).to.eq(constants.NULL_ADDRESS);
});
});
describe('getCurrentContext', () => {
it('should return the sender address when there is not a saved context address', async () => {
const currentContextAddress = await transactionsContract.getCurrentContextAddress.callAsync({