def test_stake_part_set_unstake_update(self): part = StakePart() part.set_complete(True) stake = 100 block_height = 10 part.add_stake(100) unstake = stake part.set_unstake(block_height, unstake) self.assertEqual(0, part.stake) self.assertEqual(stake, part.unstake) self.assertEqual(block_height, part.unstake_block_height) self.assertTrue( part.is_set(BasePartState.DIRTY | BasePartState.COMPLETE)) block_height += block_height unstake = 10 part.set_unstake(block_height, unstake) self.assertEqual(stake - unstake, part.stake) self.assertEqual(unstake, part.unstake) self.assertEqual(block_height, part.unstake_block_height) self.assertTrue( part.is_set(BasePartState.DIRTY | BasePartState.COMPLETE)) refund_unstake = part.normalize(block_height + 1, Revision.IISS.value) self.assertEqual(unstake, refund_unstake)
def test_stake_part_add_stake(self): part = StakePart() part.set_complete(True) stake = 100 part.add_stake(100) self.assertEqual(stake, part.stake) self.assertTrue( part.is_set(BasePartState.DIRTY | BasePartState.COMPLETE))