Skip to content

Commit

Permalink
Extend pool swap functional test to Eunos hieght
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Fieroni <[email protected]>
  • Loading branch information
bvbfan committed Apr 13, 2021
1 parent 8e5f774 commit da3f4ce
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions test/functional/feature_poolswap_mechanism.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ def set_test_params(self):
# node1: secondary tester
# node2: revert create (all)
self.setup_clean_chain = True
self.extra_args = [['-txnotokens=0', '-amkheight=0', '-bayfrontheight=0', '-bayfrontgardensheight=0'],
['-txnotokens=0', '-amkheight=0', '-bayfrontheight=0', '-bayfrontgardensheight=0'],
['-txnotokens=0', '-amkheight=0', '-bayfrontheight=0', '-bayfrontgardensheight=0']]
self.extra_args = [
['-txnotokens=0', '-amkheight=0', '-bayfrontheight=0', '-bayfrontgardensheight=0', '-eunosheight=120'],
['-txnotokens=0', '-amkheight=0', '-bayfrontheight=0', '-bayfrontgardensheight=0', '-eunosheight=120'],
['-txnotokens=0', '-amkheight=0', '-bayfrontheight=0', '-bayfrontgardensheight=0', '-eunosheight=120']
]

# SET parameters for create tokens and pools
#========================
Expand All @@ -49,12 +51,6 @@ def set_test_params(self):
# Set gov: 2 tx
# PoolSwap: 1 pool * 10 acc = 2 token * 10 acc = 20 tx

# count_create_pool_tx = self.COUNT_POOLS * 3
count_pool_token = self.COUNT_POOLS * 2
# count_mint_and_sent = count_pool_token * 4
# count_add_liquidity = count_pool_token * self.COUNT_ACCOUNT
self.COUNT_POOLSWAP = count_pool_token * self.COUNT_ACCOUNT

# self.COUNT_TX = count_create_pool_tx + count_mint_and_sent + count_add_liquidity + 2 + self.COUNT_POOLSWAP

def get_id_token(self, symbol):
Expand Down Expand Up @@ -228,9 +224,6 @@ def run_test(self):
self.nodes[0].generate(100)
self.sync_all()

# Stop node #2 for future revert
self.stop_node(2)

owner = self.nodes[0].getnewaddress("", "legacy")
self.nodes[0].generate(1)

Expand All @@ -243,7 +236,7 @@ def run_test(self):

print("Generating pools...")
self.create_pools(owner)
assert_equal(len(self.nodes[0].listtokens({}, False)), self.COUNT_POOLS * 4)
assert_equal(len(self.nodes[0].listtokens({}, False)), (3 * self.COUNT_POOLS) + 1)
assert_equal(len(self.nodes[0].listpoolpairs({}, False)), self.COUNT_POOLS)
print("Generate " + str(self.COUNT_POOLS) + " pools and " + str(self.COUNT_POOLS * 2) + " tokens")

Expand Down Expand Up @@ -296,32 +289,28 @@ def run_test(self):
assert(g2 == {'LP_DAILY_DFI_REWARD': Decimal(self.LP_DAILY_DFI_REWARD)} )
print("Set governance variables")

# Stop node #2 for future revert
self.stop_node(2)

print("Swapping tokens...")
start_time = time.time()
self.poolswap()
end_time = time.time() - start_time
print("Tokens exchanged")
print("Elapsed time: {} s".format(end_time))

print("Generating block...")
start_time = time.time()
self.nodes[0].generate(self.COUNT_POOLSWAP)
end_time = time.time() - start_time
print("Elapsed time: {} s".format(end_time))

# REVERTING:
#========================
print ("Reverting...")
self.start_node(2)
self.nodes[2].generate(20)
self.nodes[2].generate(5)

connect_nodes_bi(self.nodes, 1, 2)
self.sync_blocks()

#assert_equal(self.nodes[0].getaccount(accountGold, {}, True)[idGold], initialGold)
#assert_equal(self.nodes[0].getaccount(accountSilver, {}, True)[idSilver], initialSilver)

#assert_equal(len(self.nodes[0].getrawmempool()), self.COUNT_TX)
assert(self.nodes[0].getblockcount() == 120) # eunos
print("Swapping tokens after eunos height...")
self.poolswap()


if __name__ == '__main__':
Expand Down

0 comments on commit da3f4ce

Please sign in to comment.