Add TxPriorityMock.sol for posdao-test-setup
This commit is contained in:
parent
1c64b4d1b9
commit
f02fd45c68
|
@ -20,9 +20,9 @@ contract TxPriority {
|
|||
|
||||
BokkyPooBahsRedBlackTreeLibrary.Tree internal _weightsTree; // sorted tree of destination weights
|
||||
|
||||
address[] private _sendersWhitelist; // an array of whitelisted senders
|
||||
Destination[] private _minGasPrices; // an array of min gas price rules
|
||||
mapping(address => mapping(bytes4 => uint256)) private _minGasPriceIndex;
|
||||
address[] internal _sendersWhitelist; // an array of whitelisted senders
|
||||
Destination[] internal _minGasPrices; // an array of min gas price rules
|
||||
mapping(address => mapping(bytes4 => uint256)) internal _minGasPriceIndex;
|
||||
|
||||
uint256 public weightsCount;
|
||||
mapping(uint256 => Destination) public destinationByWeight;
|
||||
|
|
|
@ -40,7 +40,7 @@ async function main() {
|
|||
'Registry',
|
||||
'StakingAuRa',
|
||||
'TxPermission',
|
||||
'TxPriority',
|
||||
'TxPriorityMock',
|
||||
'ValidatorSetAuRa',
|
||||
];
|
||||
|
||||
|
@ -57,6 +57,8 @@ async function main() {
|
|||
|
||||
if (contractName == 'AdminUpgradeabilityProxy') {
|
||||
dir = 'contracts/upgradeability/';
|
||||
} else if (contractName == 'TxPriorityMock') {
|
||||
dir = 'test/mockContracts/';
|
||||
} else if (contractName == 'StakingAuRa' && erc20Restricted) {
|
||||
realContractName = 'StakingAuRaCoins';
|
||||
dir = 'contracts/base/';
|
||||
|
@ -157,9 +159,9 @@ async function main() {
|
|||
};
|
||||
|
||||
// Build TxPriority contract
|
||||
const txPriorityContract = new web3.eth.Contract(contractsCompiled['TxPriority'].abi);
|
||||
deploy = await txPriorityContract.deploy({data: '0x' + contractsCompiled['TxPriority'].bytecode, arguments: [
|
||||
owner
|
||||
const txPriorityContract = new web3.eth.Contract(contractsCompiled['TxPriorityMock'].abi);
|
||||
deploy = await txPriorityContract.deploy({data: '0x' + contractsCompiled['TxPriorityMock'].bytecode, arguments: [
|
||||
owner, true
|
||||
]});
|
||||
const txPriorityContractItem = {
|
||||
balance: '0',
|
||||
|
|
|
@ -32,7 +32,13 @@ async function compile(dir, contractName) {
|
|||
try {
|
||||
content = fs.readFileSync(dir + '../' + path);
|
||||
} catch (e) {
|
||||
content = fs.readFileSync(dir + '../node_modules/' + path);
|
||||
if (e.code == 'ENOENT') {
|
||||
try {
|
||||
content = fs.readFileSync(dir + '../../' + path);
|
||||
} catch (e) {
|
||||
content = fs.readFileSync(dir + '../node_modules/' + path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const TxPriority = artifacts.require('TxPriorityMock');
|
||||
const TxPriorityMock = artifacts.require('TxPriorityMock');
|
||||
|
||||
const ERROR_MSG = 'VM Exception while processing transaction: revert';
|
||||
const BN = web3.utils.BN;
|
||||
|
@ -14,7 +14,7 @@ contract('TxPriority', async accounts => {
|
|||
|
||||
beforeEach(async () => {
|
||||
owner = accounts[0];
|
||||
txPriority = await TxPriority.new();
|
||||
txPriority = await TxPriorityMock.new(owner, false);
|
||||
});
|
||||
|
||||
describe('setPriority()', async () => {
|
||||
|
|
|
@ -6,6 +6,18 @@ import '../../contracts/TxPriority.sol';
|
|||
|
||||
contract TxPriorityMock is TxPriority {
|
||||
|
||||
constructor(address _owner, bool _applyInitTestRules) public TxPriority(_owner) {
|
||||
if (_applyInitTestRules) {
|
||||
// Apply initial test rules for posdao-test-setup
|
||||
_weightsTree.insert(4);
|
||||
destinationByWeight[4] = Destination(0x1100000000000000000000000000000000000001, 0x00000000, 4);
|
||||
weightByDestination[0x1100000000000000000000000000000000000001][0x00000000] = 4;
|
||||
weightsCount = 1;
|
||||
_sendersWhitelist.push(address(0x32E4E4c7c5d1CEa5db5F9202a9E4D99E56c91a24));
|
||||
_minGasPrices.push(Destination(0x1100000000000000000000000000000000000001, 0x48aaa4a2, 100000000000));
|
||||
}
|
||||
}
|
||||
|
||||
function firstWeightInTree() external view returns(uint256) {
|
||||
return _weightsTree.first();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue