Merge branch 'master' of gitlab.com:grassrootseconomics/cic-internal-integration into philip/management-integration-tests
This commit is contained in:
commit
f39468d41f
@ -72,7 +72,9 @@ class CallbackFilter(SyncFilter):
|
||||
#transfer_data['token_address'] = tx.inputs[0]
|
||||
faucet_contract = tx.inputs[0]
|
||||
|
||||
o = Faucet.token(faucet_contract, sender_address=self.caller_address)
|
||||
c = Faucet(self.chain_spec)
|
||||
|
||||
o = c.token(faucet_contract, sender_address=self.caller_address)
|
||||
r = conn.do(o)
|
||||
transfer_data['token_address'] = add_0x(c.parse_token(r))
|
||||
|
||||
|
@ -4,7 +4,7 @@ import sys
|
||||
import logging
|
||||
|
||||
# external imports
|
||||
from chainlib.eth.erc20 import ERC20
|
||||
from eth_erc20 import ERC20
|
||||
|
||||
# local imports
|
||||
from cic_eth.api import Api
|
||||
|
@ -14,9 +14,9 @@ from chainlib.eth.tx import (
|
||||
Tx,
|
||||
)
|
||||
from chainlib.eth.block import Block
|
||||
from chainlib.eth.erc20 import ERC20
|
||||
from eth_erc20 import ERC20
|
||||
from sarafu_faucet import MinterFaucet
|
||||
from eth_accounts_index import AccountRegistry
|
||||
from eth_accounts_index.registry import AccountRegistry
|
||||
from potaahto.symbols import snake_and_camel
|
||||
from hexathon import add_0x
|
||||
|
||||
@ -26,7 +26,6 @@ from cic_eth.runnable.daemons.filters.callback import CallbackFilter
|
||||
logg = logging.getLogger()
|
||||
|
||||
|
||||
@pytest.mark.skip()
|
||||
def test_transfer_tx(
|
||||
default_chain_spec,
|
||||
init_database,
|
||||
@ -66,7 +65,6 @@ def test_transfer_tx(
|
||||
assert transfer_type == 'transfer'
|
||||
|
||||
|
||||
@pytest.mark.skip()
|
||||
def test_transfer_from_tx(
|
||||
default_chain_spec,
|
||||
init_database,
|
||||
|
@ -4,7 +4,7 @@ import logging
|
||||
# external imports
|
||||
import pytest
|
||||
from chainlib.eth.nonce import RPCNonceOracle
|
||||
from chainlib.eth.erc20 import ERC20
|
||||
from eth_erc20 import ERC20
|
||||
from chainlib.eth.tx import receipt
|
||||
|
||||
# local imports
|
||||
|
@ -9,7 +9,7 @@ import celery
|
||||
from chainlib.connection import RPCConnection
|
||||
from chainlib.eth.nonce import RPCNonceOracle
|
||||
from chainlib.eth.tx import receipt
|
||||
from eth_accounts_index import AccountRegistry
|
||||
from eth_accounts_index.registry import AccountRegistry
|
||||
from hexathon import strip_0x
|
||||
from chainqueue.db.enum import StatusEnum
|
||||
from chainqueue.db.models.otx import Otx
|
||||
|
@ -4,7 +4,7 @@ import logging
|
||||
# external imports
|
||||
import pytest
|
||||
import celery
|
||||
from chainlib.eth.erc20 import ERC20
|
||||
from eth_erc20 import ERC20
|
||||
from chainlib.eth.nonce import RPCNonceOracle
|
||||
from chainlib.eth.tx import (
|
||||
receipt,
|
||||
|
@ -3,7 +3,7 @@ from chainlib.eth.nonce import RPCNonceOracle
|
||||
from chainlib.eth.tx import (
|
||||
receipt,
|
||||
)
|
||||
from eth_address_declarator import AddressDeclarator
|
||||
from eth_address_declarator import Declarator
|
||||
from hexathon import add_0x
|
||||
|
||||
# local imports
|
||||
@ -23,7 +23,7 @@ def test_translate(
|
||||
|
||||
nonce_oracle = RPCNonceOracle(contract_roles['CONTRACT_DEPLOYER'], eth_rpc)
|
||||
|
||||
c = AddressDeclarator(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle)
|
||||
c = Declarator(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle)
|
||||
|
||||
description = 'alice'.encode('utf-8').ljust(32, b'\x00').hex()
|
||||
(tx_hash_hex, o) = c.add_declaration(address_declarator, contract_roles['CONTRACT_DEPLOYER'], agent_roles['ALICE'], add_0x(description))
|
||||
|
@ -8,7 +8,7 @@ from chainlib.eth.tx import (
|
||||
count,
|
||||
receipt,
|
||||
)
|
||||
from chainlib.eth.erc20 import ERC20
|
||||
from eth_erc20 import ERC20
|
||||
from chainlib.eth.nonce import RPCNonceOracle
|
||||
|
||||
# local imports
|
||||
|
@ -9,3 +9,7 @@ class AlreadyInitializedError(Exception):
|
||||
class PleaseCommitFirstError(Exception):
|
||||
"""Raised when there exists uncommitted changes in the code while trying to build out the package."""
|
||||
pass
|
||||
|
||||
|
||||
class NotificationSendError(Exception):
|
||||
"""Raised when a notification failed to due to some error as per the service responsible for dispatching the notification."""
|
||||
|
19
apps/cic-notify/cic_notify/ext/enums.py
Normal file
19
apps/cic-notify/cic_notify/ext/enums.py
Normal file
@ -0,0 +1,19 @@
|
||||
# standard imports
|
||||
from enum import IntEnum
|
||||
|
||||
|
||||
class AfricasTalkingStatusCodes(IntEnum):
|
||||
PROCESSED = 100
|
||||
SENT = 101
|
||||
QUEUED = 102
|
||||
RISK_HOLD = 401
|
||||
INVALID_SENDER_ID = 402
|
||||
INVALID_PHONE_NUMBER = 403
|
||||
UNSUPPORTED_NUMBER_TYPE = 404
|
||||
INSUFFICIENT_BALANCE = 405
|
||||
USER_IN_BLACKLIST = 406
|
||||
COULD_NOT_ROUTE = 407
|
||||
INTERNAL_SERVER_ERROR = 500
|
||||
GATEWAY_ERROR = 501
|
||||
REJECTED_BY_GATEWAY = 502
|
||||
|
@ -6,7 +6,8 @@ import celery
|
||||
import africastalking
|
||||
|
||||
# local imports
|
||||
from cic_notify.error import NotInitializedError, AlreadyInitializedError
|
||||
from cic_notify.error import NotInitializedError, AlreadyInitializedError, NotificationSendError
|
||||
from cic_notify.ext.enums import AfricasTalkingStatusCodes
|
||||
|
||||
logg = logging.getLogger()
|
||||
celery_app = celery.current_app
|
||||
@ -50,10 +51,27 @@ class AfricasTalkingNotifier:
|
||||
if self.sender_id:
|
||||
response = self.api_client.send(message=message, recipients=[recipient], sender_id=self.sender_id)
|
||||
logg.debug(f'Africastalking response sender-id {response}')
|
||||
|
||||
else:
|
||||
response = self.api_client.send(message=message, recipients=[recipient])
|
||||
logg.debug(f'africastalking response no-sender-id {response}')
|
||||
|
||||
recipients = response.get('Recipients')
|
||||
|
||||
if len(recipients) != 1:
|
||||
status = response.get('SMSMessageData').get('Message')
|
||||
raise NotificationSendError(f'Unexpected number of recipients: {len(recipients)}. Status: {status}')
|
||||
|
||||
status_code = recipients[0].get('statusCode')
|
||||
status = recipients[0].get('status')
|
||||
|
||||
if status_code not in [
|
||||
AfricasTalkingStatusCodes.PROCESSED.value,
|
||||
AfricasTalkingStatusCodes.SENT.value,
|
||||
AfricasTalkingStatusCodes.QUEUED.value
|
||||
]:
|
||||
raise NotificationSendError(f'Sending notification failed due to: {status}')
|
||||
|
||||
|
||||
@celery_app.task
|
||||
def send(message, recipient):
|
||||
|
@ -9,7 +9,7 @@ import semver
|
||||
|
||||
logg = logging.getLogger()
|
||||
|
||||
version = (0, 4, 0, 'alpha.4')
|
||||
version = (0, 4, 0, 'alpha.5')
|
||||
|
||||
version_object = semver.VersionInfo(
|
||||
major=version[0],
|
||||
|
@ -102,7 +102,7 @@ class MetadataRequestsHandler(Metadata):
|
||||
'digest': json.loads(data).get('digest'),
|
||||
}
|
||||
}
|
||||
formatted_data = json.dumps(formatted_data).encode('utf-8')
|
||||
formatted_data = json.dumps(formatted_data)
|
||||
result = make_request(method='PUT', url=self.url, data=formatted_data, headers=self.headers)
|
||||
logg.info(f'signed metadata submission status: {result.status_code}.')
|
||||
metadata_http_error_handler(result=result)
|
||||
@ -116,8 +116,10 @@ class MetadataRequestsHandler(Metadata):
|
||||
"""This function is responsible for querying the metadata server for data corresponding to a unique pointer."""
|
||||
result = make_request(method='GET', url=self.url)
|
||||
metadata_http_error_handler(result=result)
|
||||
response_data = result.content
|
||||
data = json.loads(response_data.decode('utf-8'))
|
||||
response_data = result.json()
|
||||
data = json.loads(response_data)
|
||||
if not isinstance(data, dict):
|
||||
raise ValueError(f'Invalid data object: {data}.')
|
||||
if result.status_code == 200 and self.cic_type == ':cic.person':
|
||||
person = Person()
|
||||
deserialized_person = person.deserialize(person_data=data)
|
||||
|
@ -1,12 +1,12 @@
|
||||
sw:
|
||||
kenya:
|
||||
initial_language_selection: |-
|
||||
CON Welcome to Sarafu
|
||||
CON Karibu Sarafu Network
|
||||
1. English
|
||||
2. Kiswahili
|
||||
3. Help
|
||||
initial_pin_entry: |-
|
||||
CON Tafadhali weka PIN ili kudhibiti akaunti yako.
|
||||
CON Tafadhali weka pin mpya yenye nambari nne kwa akaunti yako
|
||||
0. Nyuma
|
||||
initial_pin_confirmation: |-
|
||||
CON Weka PIN yako tena
|
||||
@ -21,12 +21,13 @@ sw:
|
||||
CON Weka jinsia yako
|
||||
1. Mwanaume
|
||||
2. Mwanamke
|
||||
3. Nyngine
|
||||
0. Nyuma
|
||||
enter_location: |-
|
||||
CON Weka eneo lako
|
||||
0. Nyuma
|
||||
enter_products: |-
|
||||
CON Tafadhali weka bidhaa ama huduma unauza
|
||||
CON Weka bidhaa ama huduma unauza
|
||||
0. Nyuma
|
||||
start: |-
|
||||
CON Salio %{account_balance} %{account_token_name}
|
||||
@ -155,7 +156,7 @@ sw:
|
||||
99. Ondoka
|
||||
exit_insufficient_balance: |-
|
||||
CON Malipo ya %{amount} %{token_symbol} kwa %{recipient_information} halijakamilika kwa sababu salio lako haitoshi.
|
||||
Akaunti yako ya Sarafu-Network ina salio ifuatayo: %{token_balance}
|
||||
Akaunti yako ya Sarafu ina salio ifuatayo: %{token_balance}
|
||||
00. Nyuma
|
||||
99. Ondoka
|
||||
invalid_service_code: |-
|
||||
@ -169,4 +170,4 @@ sw:
|
||||
00. Nyuma
|
||||
99. Ondoka
|
||||
account_creation_prompt: |-
|
||||
Akaunti yako ya Sarafu inatayarishwa. Utapokea ujumbe wa SMS akaunti yako ikiwa tayari.
|
||||
Akaunti yako ya Sarafu inatayarishwa. Utapokea ujumbe wa SMS akaunti yako ikiwa tayari.
|
||||
|
@ -171,6 +171,7 @@ if __name__ == '__main__':
|
||||
logg.error('load error for {}: {}'.format(y, e))
|
||||
continue
|
||||
f.close()
|
||||
logg.debug('deserializing {} {}'.format(filepath, o))
|
||||
u = Person.deserialize(o)
|
||||
|
||||
new_address = register_eth(i, u)
|
||||
|
@ -105,7 +105,7 @@ def genId(addr, typ):
|
||||
def genDate():
|
||||
|
||||
ts = random.randint(ts_then, ts_now)
|
||||
return datetime.datetime.fromtimestamp(ts).timestamp()
|
||||
return int(datetime.datetime.fromtimestamp(ts).timestamp())
|
||||
|
||||
|
||||
def genPhone():
|
||||
@ -193,6 +193,7 @@ def prepareLocalFilePath(datadir, address):
|
||||
if __name__ == '__main__':
|
||||
|
||||
base_dir = os.path.join(user_dir, 'old')
|
||||
ussd_dir = os.path.join(user_dir, 'ussd')
|
||||
os.makedirs(base_dir, exist_ok=True)
|
||||
|
||||
fa = open(os.path.join(user_dir, 'balances.csv'), 'w')
|
||||
@ -223,6 +224,8 @@ if __name__ == '__main__':
|
||||
f = open('{}/{}'.format(d, uid + '.json'), 'w')
|
||||
json.dump(o.serialize(), f)
|
||||
f.close()
|
||||
|
||||
d = prepareLocalFilePath(ussd_dir, uid)
|
||||
x = open('{}/{}'.format(d, uid + '_ussd_data.json'), 'w')
|
||||
json.dump(ussd_data, x)
|
||||
x.close()
|
||||
|
@ -23,7 +23,7 @@ from chainlib.eth.connection import EthHTTPConnection
|
||||
from chainlib.eth.gas import RPCGasOracle
|
||||
from chainlib.eth.nonce import RPCNonceOracle
|
||||
from cic_types.processor import generate_metadata_pointer
|
||||
from eth_accounts_index import AccountRegistry
|
||||
from eth_accounts_index.registry import AccountRegistry
|
||||
from eth_contract_registry import Registry
|
||||
from crypto_dev_signer.keystore.dict import DictKeystore
|
||||
from crypto_dev_signer.eth.signer.defaultsigner import ReferenceSigner as EIP155Signer
|
||||
|
@ -446,9 +446,9 @@ services:
|
||||
PGPASSWORD: ${DATABASE_PASSWORD:-tralala}
|
||||
CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
|
||||
CELERY_RESULT_URL: ${CELERY_BROKER_URL:-redis://redis}
|
||||
TASKS_AFRICASTALKING: $TASKS_AFRICASTALKING
|
||||
TASKS_SMS_DB: $TASKS_SMS_DB
|
||||
TASKS_LOG: $TASKS_LOG
|
||||
AFRICASTALKING_API_USERNAME: $AFRICASTALKING_API_USERNAME
|
||||
AFRICASTALKING_API_KEY: $AFRICASTALKING_API_KEY
|
||||
AFRICASTALKING_API_SENDER_ID: $AFRICASTALKING_API_SENDER_ID
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
|
Loading…
Reference in New Issue
Block a user