Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#86dthh0zp - Update native PolicyContract #1254

Merged
merged 1 commit into from
May 24, 2024
Merged

Conversation

luc10921
Copy link
Contributor

Summary or solution description
Added get_attribute_fee and set_attribute_fee to the PolicyContract from boa3.sc.contracts.
Added TransactionAttributeType to boa3.sc.types

How to Reproduce

from boa3.sc.compiletime import public
from boa3.sc.contracts import PolicyContract
from boa3.sc.types import TransactionAttributeType
@public
def main(tx_att: TransactionAttributeType, value: int):
PolicyContract.set_attribute_fee(tx_att, value)
@public
def get_tx_attr(tx_att: TransactionAttributeType) -> int:
return PolicyContract.get_attribute_fee(tx_att)

Tests

async def test_get_attribute_fee(self):
await self.set_up_contract('GetAttributeFee.py')
result, _ = await self.call('main', [TransactionAttributeType.HIGH_PRIORITY], return_type=int)
self.assertIsInstance(result, int)
with self.assertRaises(boatestcase.FaultException) as context:
await self.call('main', [19999999], return_type=int)
self.assertRegex(str(context.exception), 'bigint does not fit into uint8')
with self.assertRaises(boatestcase.FaultException) as context:
await self.call('main', [20], return_type=int)
self.assertRegex(str(context.exception), 'invalid attribute type: 20')
async def test_set_attribute_fee(self):
await self.set_up_contract('SetAttributeFee.py')
signer = verification.Signer(
self.genesis.script_hash,
verification.WitnessScope.GLOBAL
)
result, _ = await self.call('main', [TransactionAttributeType.HIGH_PRIORITY, 100],
return_type=None, signers=[signer], signing_accounts=[self.genesis])
result, _ = await self.call('get_tx_attr', [TransactionAttributeType.HIGH_PRIORITY], return_type=int)
self.assertEqual(result, 100)
with self.assertRaises(boatestcase.FaultException) as context:
await self.call('main', [TransactionAttributeType.HIGH_PRIORITY, 100], return_type=int)
self.assertRegex(str(context.exception), 'invalid committee signature')

Platform:

  • OS: Windows 11 x64
  • Python version: Python 3.11

@luc10921 luc10921 requested a review from meevee98 May 16, 2024 19:46
@luc10921 luc10921 self-assigned this May 16, 2024
@melanke
Copy link
Contributor

melanke commented May 16, 2024

Task linked: CU-86dthh0zp Update native PolicyContract

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 91.191% (-0.02%) from 91.215%
when pulling 50bf881 on CU-86dthh0zp
into 49731b6 on development.

@meevee98 meevee98 merged commit 1d1fbe5 into development May 24, 2024
5 checks passed
@meevee98 meevee98 deleted the CU-86dthh0zp branch May 24, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants