Skip to content

Commit

Permalink
Merge pull request #2006 from aeternity/local-middleware
Browse files Browse the repository at this point in the history
Run middleware locally for tests, require v1.81.0
  • Loading branch information
davidyuk authored Jul 22, 2024
2 parents 61c161f + c6e9556 commit 88409c2
Show file tree
Hide file tree
Showing 8 changed files with 286 additions and 153 deletions.
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ services:
# TODO: remove after releasing https://github.com/aeternity/aesophia_http/pull/133
healthcheck:
interval: 2s

middleware:
# TODO: use upstream after solving https://github.com/aeternity/ae_mdw/issues/1758
image: davidyuk/temp:mdw-dev-mode-1.81.0
ports: [4000:4000, 4001:4001, 4013:3013, 4313:3313]
volumes:
- ./docker/middleware.yaml:/home/aeternity/aeternity.yaml
stop_grace_period: 0s
29 changes: 29 additions & 0 deletions docker/middleware.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# yaml-language-server: $schema=https://github.com/aeternity/aeternity/raw/master/apps/aeutils/priv/aeternity_config_schema.json

system:
dev_mode: true
plugins:
- name: aeplugin_dev_mode

http:
endpoints:
dry-run: true

dev_mode:
auto_emit_microblocks: true

chain:
persist: false
hard_forks:
"1": 0
"6": 1
genesis_accounts:
ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E: 10000000000000000000000

# TODO: remove after solving https://github.com/aeternity/ae_mdw/issues/1760
fork_management:
network_id: ae_dev

# TODO remove after solving https://github.com/aeternity/ae_mdw/issues/1760#issuecomment-2102872638
mining:
beneficiary: ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E
2 changes: 1 addition & 1 deletion src/Middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class Middleware
allowInsecureConnection: true,
additionalPolicies: [
...ignoreVersion ? [] : [
genVersionCheckPolicy('middleware', getVersion, '1.77.5', '2.0.0'),
genVersionCheckPolicy('middleware', getVersion, '1.81.0', '2.0.0'),
],
genRequestQueuesPolicy(),
genCombineGetRequestsPolicy(),
Expand Down
6 changes: 2 additions & 4 deletions src/index-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ export { default as CompilerBase } from './contract/compiler/Base';
export { default as CompilerHttp } from './contract/compiler/Http';
export { default as Channel } from './channel/Contract';
export {
default as _MiddlewareSubscriber,
MiddlewareSubscriberError as _MiddlewareSubscriberError,
MiddlewareSubscriberDisconnected as _MiddlewareSubscriberDisconnected,
default as MiddlewareSubscriber, MiddlewareSubscriberError, MiddlewareSubscriberDisconnected,
} from './MiddlewareSubscriber';
export { default as _Middleware } from './Middleware';
export { default as Middleware } from './Middleware';

export { default as connectionProxy } from './aepp-wallet-communication/connection-proxy';
export {
Expand Down
192 changes: 105 additions & 87 deletions test/integration/Middleware.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { describe, it } from 'mocha';
import { describe, before, it } from 'mocha';
import { expect } from 'chai';
import '../index';
import { _Middleware } from '../../src';
import resetMiddleware, { presetAccountAddress } from './reset-middleware';
import { Middleware } from '../../src';
import { assertNotNull } from '../utils';

describe('Middleware API', () => {
// TODO: remove after solving https://github.com/aeternity/ae_mdw/issues/1336
const middleware = new _Middleware('https://testnet.aeternity.io/mdw/');
const middleware = new Middleware('http://localhost:4000');

before(async () => {
await resetMiddleware();
});

it('gets status', async () => {
const res = await middleware.getStatus();
Expand All @@ -17,123 +21,126 @@ describe('Middleware API', () => {
},
mdwGensPerMinute: res.mdwGensPerMinute,
mdwHeight: res.mdwHeight,
mdwLastMigration: res.mdwLastMigration,
mdwRevision: res.mdwRevision,
mdwLastMigration: 20240702122227,
mdwRevision: '6252c01f',
mdwSynced: true,
mdwSyncing: true,
mdwTxIndex: res.mdwTxIndex,
mdwVersion: res.mdwVersion,
mdwVersion: '1.81.0',
nodeHeight: res.nodeHeight,
nodeProgress: 100,
nodeRevision: res.nodeRevision,
nodeRevision: 'b394868693b70a3a7ce5dfec144f718f60e79964',
nodeSyncing: false,
nodeVersion: res.nodeVersion,
nodeVersion: '7.1.0',
};
expect(res).to.be.eql(expectedRes);
});

it('gets account activities', async () => {
const res = await middleware.getAccountActivities('ak_DtJrupsqqByQag76NrxAAimmkYJMk7on7z3xktdZpdkmxKQak');
const res = await middleware.getAccountActivities(presetAccountAddress);
const expectedRes: typeof res = {
data: [{
blockHash: 'mh_LAo6Cg6d8LGDpxJ3se2aGJZbCubDZyC6GonHK58MKiW4a4LWb',
blockTime: 1684995426848,
height: 779178,
blockHash: 'mh_28wMvNExkFqRSGc2KchZzQWr9QrNiHCFD3sBeMNCM5shK9iqXw',
blockTime: 1721213472190,
height: 3,
payload: {
kind: 'fee_lock_name',
amount: 3,
ref_tx_hash: 'th_Wt9hi3oaWpr5mfR2zJHPJg7bAWkYbPwajoS361NVVHmeQ3Wmx',
},
type: 'InternalTransferEvent',
}, {
blockHash: 'mh_28wMvNExkFqRSGc2KchZzQWr9QrNiHCFD3sBeMNCM5shK9iqXw',
blockTime: 1721213472190,
height: 3,
payload: {
block_hash: 'mh_LAo6Cg6d8LGDpxJ3se2aGJZbCubDZyC6GonHK58MKiW4a4LWb',
block_height: 779178,
encoded_tx: 'tx_+QEKCwHAuQEE+QEBUQKhAR1BkBtnVYcqjIhl7aOh9hEy9W96OFTeeQreTa3ExE/auG8rEWzyVws7Ap8AoLb4BE1sdD+LZw3SM+libDajr+a976yRMKi9b7k5whrinwEBAFGw3Ke65y52/KhwL5lYHOlRuOIZZy2V190M5H1ywIgN5fAylDfLImUL3WDwC4UAHa6EcyMc3Pl8apaHFuO79AMDhkduhMz4AILDUIQ7msoAuFr4WAsBwLhT+FEMAaEBHUGQG2dVhyqMiGXto6H2ETL1b3o4VN55Ct5NrcTET9qhAUCcLjbyYA3yE1vkfr0zC0M4oNrQ3lNoPHDD6EzUnVzAcIYPJvVhyAAAAIAv4MYN',
hash: 'th_YHj5aB6JzHciY5f6jqgtso8u2iY9p6MT9RV96FwXQNS1MpSML',
micro_index: 18,
micro_time: 1684995426848,
block_hash: 'mh_28wMvNExkFqRSGc2KchZzQWr9QrNiHCFD3sBeMNCM5shK9iqXw',
block_height: 3,
encoded_tx: 'tx_+KULAfhCuEDWbZq1WeArvSAaNYZWvXvTwRPiiakFeSJ1XGavpe/A47SNYu6wKSdeChh3IZtTMJIblgbluqE0eCrW0tXfv+4GuF34WyACoQGlDe8oTWOIBGKIUgMgu3jBZWwwfAJEB/vhPQUWEAbEqgKkOWJLazQxMHJ0NFpFblBablh5RkoyS292c0lBenptLmNoYWluAIcBxr9SY0AAhg9Vhk+YAAZA2OYv',
hash: 'th_Wt9hi3oaWpr5mfR2zJHPJg7bAWkYbPwajoS361NVVHmeQ3Wmx',
micro_index: 0,
micro_time: 1721213472190,
signatures: [
'sg_V46KfD6DhcDXP3FKnXY3YUps67zWxjrQphen95VFwj9GiMdDAnVuMdgumF2v8Gu3xTMJJB9n56yr5JQrcpW2d7oFfh9Ua',
],
tx: {
abi_version: 3,
auth_data: 'cb_KxFs8lcLOwKfAKC2+ARNbHQ/i2cN0jPpYmw2o6/mve+skTCovW+5OcIa4p8BAQBRsNynuucudvyocC+ZWBzpUbjiGWctldfdDOR9csCIDeXwMpQ3yyJlC91g8AuFAB2uhHMjHNz5fGqWhxbju/QDsvQe5g==',
fee: 78540000000000,
ga_id: 'ak_DtJrupsqqByQag76NrxAAimmkYJMk7on7z3xktdZpdkmxKQak',
gas: 50000,
gas_price: 1000000000,
gas_used: 8444,
return_type: 'ok',
tx: {
signatures: [],
tx: {
amount: 112,
fee: 16660000000000,
nonce: 0,
payload: 'ba_Xfbg4g==',
recipient_id: 'ak_VTNurrhRhJBVK19JfUnEv4qgdZJT7DUghxz3ACEFBNKgw8R3D',
sender_id: 'ak_DtJrupsqqByQag76NrxAAimmkYJMk7on7z3xktdZpdkmxKQak',
type: 'SpendTx',
version: 1,
},
},
type: 'GAMetaTx',
account_id: 'ak_2Fh6StA76AKdy8qsGdkEfkQyVmAYc2XE1irWRnDgXKhmBLKoXg',
fee: 16860000000000,
name: '9bKk410rt4ZEnPZnXyFJ2KovsIAzzm.chain',
name_fee: 500000000000000,
name_id: 'nm_27MpcZebrNCLB8AWaJBjp6TrzdjwMWKDJQDBnTWb82E2sut7P7',
name_salt: 0,
nonce: 2,
ttl: 6,
type: 'NameClaimTx',
version: 2,
},
},
type: 'GAMetaTxEvent',
type: 'NameClaimTxEvent',
}, {
blockHash: 'mh_2R1PVwTNP3Jha7oRby9Me3SRBP4R9he6RMH6eCCJGyVBHAzy5f',
blockTime: 1684995366595,
height: 779178,
blockHash: 'mh_Regp5RaGeK2mxpQmifSgbrF4DwXiQNkkt8VjFnkNB4NK5v3St',
blockTime: 1721213472106,
height: 2,
payload: {
block_hash: 'mh_2R1PVwTNP3Jha7oRby9Me3SRBP4R9he6RMH6eCCJGyVBHAzy5f',
block_height: 779178,
encoded_tx: 'tx_+QayCwH4QrhAwG9pipSjLr6vd/WIyokLy1Pj3aybjCnlZeJwMacD4T6rOgl6qQzbzWsR6w5caPmnZEQ9hXUOtTVH/T3L3MHpA7kGafkGZlABoQEdQZAbZ1WHKoyIZe2jofYRMvVvejhU3nkK3k2txMRP2gG5Bd75BdtGA6AhYBMZ2y1+tz8gF0bhQfiQAXA++XyzbIlh5YVUJMgWO8C5Ba25BD/+PR6JaAA3ADcERwBnRwCHAzcANwEHNwEHhwI3ADcBNwIHBwcMAoIMAoQMAoYMAognDAgA/kTWRB8ANwFHADcAVQAjBAAHDAT7A61NYXN0ZXIgbm90IGFsbG93ZWQgdG8gYmUgdGhlIGFjY291bnQgaXRzZWxmGg6ELwAaDoavggABARsrb4cHGv1JjP/Ab4Xo1KUPwBoGggAaDogCAQM//kZnE6AANwKXQAeXQAwBAgwBAAIDEd95h1wCAxGNc7oMAgMRq4gy0R0AAP5XMYoXADcBhwI3ADcBNwIHBzcAVQAgIIIHDAT7Az1Pbmx5IGZvciBtYXN0ZXIaBoYAAQM//mzyVwsANwMHRwCXbwAXIiQ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WdldEFyZ4IvAIU4LjAuMACDCAADhkdlNJ1oAAUAAEyEO5rKAIcrEUTWRB8/Bmn2yg==',
hash: 'th_2JMR7C1DjrGeZWyyLMkccRLga1Lct8Syy9hcZKD9PEZkN5JvSD',
micro_index: 0,
micro_time: 1721213472106,
signatures: [
'sg_SBD5RkjMkfDM8KGJTgTTgmfXaimac2cGy4x39efXZjrPdr5zVJAmqu8dLiMNoVX1FHTESERRvejAnDVDjxLq6x2gb1SzK',
'sg_HXRkFjgjsFmFLZ1ywBgYj9VouQK1BySqCViALxq3ge69a86aDgd1ESqNXhCLebh7fH6SohTjbLXXxhjPnYXaGJfiX7DQV',
],
tx: {
abi_version: 3,
args: [
{
type: 'address',
value: 'ak_2PahBfbkrmBFfbb4FGEVErP7mChFGPYFb9eGMARU514u5V3K52',
},
],
auth_fun: '0x6cf2570b0a1599b708291e50aa3daf13d0c7f2484bc337ddad2413a37fd4a009',
auth_fun_name: 'authorize',
call_data: 'cb_KxFE1kQfG58AoLb4BE1sdD+LZw3SM+libDajr+a976yRMKi9b7k5whrijU9L2Q==',
code: 'cb_+QXbRgOgIWATGdstfrc/IBdG4UH4kAFwPvl8s2yJYeWFVCTIFjvAuQWtuQQ//j0eiWgANwA3BEcAZ0cAhwM3ADcBBzcBB4cCNwA3ATcCBwcHDAKCDAKEDAKGDAKIJwwIAP5E1kQfADcBRwA3AFUAIwQABwwE+wOtTWFzdGVyIG5vdCBhbGxvd2VkIHRvIGJlIHRoZSBhY2NvdW50IGl0c2VsZhoOhC8AGg6Gr4IAAQEbK2+HBxr9SYz/wG+F6NSlD8AaBoIAGg6IAgEDP/5GZxOgADcCl0AHl0AMAQIMAQACAxHfeYdcAgMRjXO6DAIDEauIMtEdAAD+VzGKFwA3AYcCNwA3ATcCBwc3AFUAICCCBwwE+wM9T25seSBmb3IgbWFzdGVyGgaGAAEDP/5s8lcLADcDB0cAl28AFyIkAIgHDAT7AzVOb25jZSB0b28gbG93ISQAiAcMCPsDOU5vbmNlIH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GZxOgHXRvX3NpZ24RVzGKF0lzZXRfZmVlX3Byb3RlY3Rpb24RbPJXCyVhdXRob3JpemURc7AX2ilnZXRfc2lnbmVyEY1zugylLkdBTWFpbldUZW1wb3Jhcnkuc3VwZXJoZXJvX3dhbGxldF9wcmVmaXgRq4gy0TkuU3RyaW5nLmNvbmNhdBGvdzaYYS5HQU1haW5XVGVtcG9yYXJ5LmZlZV9vaxHOQ4yJgS5HQU1haW5XVGVtcG9yYXJ5LmFsbG93ZWRfc2lnbmVyEdP2+T5tLkdBTWFpbldUZW1wb3JhcnkuYW1vdW50X29rEdmowSglZ2V0X25vbmNlEd95h1xJdG9fc2lnbl91bnByZWZpeGVkEebMjCMxZ2V0X3RydXN0ZWVzEfKsV4U5cmVtb3ZlX3RydXN0ZWUR+RLyHy1hZGRfdHJ1c3RlZYIvAIU3LjEuMAAStuVe',
contract_id: 'ct_2TRQYcmvhRrbGrNKXy8uBZX2MQbgHrZmVCEHZBAJkhs24DdeVP',
fee: 107820000000000,
gas: 597,
aexn_type: null,
amount: 0,
args: [],
call_data: 'cb_KxFE1kQfP4oEp9E=',
caller_id: 'ak_2Fh6StA76AKdy8qsGdkEfkQyVmAYc2XE1irWRnDgXKhmBLKoXg',
code: 'cb_+GhGA6Daq9LRBkSN10Qb9d5ZbvJWB+/tg8rj5OynWtj8AQ2R7cC4O57+RNZEHwA3ADcAGg6CPwEDP/6AeCCSADcBBwcBAQCYLwIRRNZEHxFpbml0EYB4IJIZZ2V0QXJngi8AhTguMC4wAHQkH9o=',
compiler_version: '8.0.0',
contract_id: 'ct_2JgVFKjJYUyJDnpJPhspX8C6RS6rFS46r3C1sy15tW9dDmPX2E',
deposit: 0,
fee: 78500000000000,
gas: 76,
gas_price: 1000000000,
gas_used: 478,
gas_used: 61,
log: [],
nonce: 1,
owner_id: 'ak_DtJrupsqqByQag76NrxAAimmkYJMk7on7z3xktdZpdkmxKQak',
owner_id: 'ak_2Fh6StA76AKdy8qsGdkEfkQyVmAYc2XE1irWRnDgXKhmBLKoXg',
return_type: 'ok',
type: 'GAAttachTx',
return_value: 'cb_Xfbg4g==',
source_hash: '2qvS0QZEjddEG/XeWW7yVgfv7YPK4+Tsp1rY/AENke0=',
ttl: 5,
type: 'ContractCreateTx',
version: 1,
vm_version: 7,
vm_version: 8,
},
},
type: 'GAAttachTxEvent',
type: 'ContractCreateTxEvent',
}, {
blockHash: 'mh_25snWYwTkU1xjPCcH592XVNzL894qSpF4yqnt8tABKGEVm6nSz',
blockTime: 1684995336526,
height: 779178,
blockHash: 'mh_2Wcpmr8PBEjj7qc78Y1dusvAKsQNuYhgoQNPsx3XdHtphvw8mT',
blockTime: 1721213471890,
height: 1,
payload: {
block_hash: 'mh_25snWYwTkU1xjPCcH592XVNzL894qSpF4yqnt8tABKGEVm6nSz',
block_height: 779178,
encoded_tx: 'tx_+K4LAfhCuEBjZgd36W2H8rB5KZzut7wvRnAsjJSD+CEg8Dbm8ivFXmDzKFauG8QJpnm9kmVnNl0xOI7xVsm0brXYTMNuAmUDuGb4ZAwBoQHhMrjx3begTmO3+pZHmlS7xSWlMafxvAzkkhIZAwZ/sKEBHUGQG2dVhyqMiGXto6H2ETL1b3o4VN55Ct5NrcTET9qIRWORgkT0AACGD39vJaAAAIKQmIlGYXVjZXQgVHiaKLKm',
hash: 'th_242zV1qXwag6iBH3Pd8zn3DQC37h4uP38CoFjkaTgT19AVKMHo',
micro_index: 7,
micro_time: 1684995336526,
block_hash: 'mh_2Wcpmr8PBEjj7qc78Y1dusvAKsQNuYhgoQNPsx3XdHtphvw8mT',
block_height: 1,
encoded_tx: 'tx_+KMLAfhCuEDgjc7zMPb+xRW+pI0L5OqwjI+OBF0ee1zgmlkXsavoYXHZw7vTx6vxaAZxxs4ts/eZhAmqVGg3EmTsRAtccKMDuFv4WQwBoQGEDJdLlxZHdkVLoRnYTtxNYFio3skrbtxXirLTC0xCAKEBpQ3vKE1jiARiiFIDILt4wWVsMHwCRAf74T0FFhAGxKqIDeC2s6dkAACGD0w2IAgABAGAJs2FDw==',
hash: 'th_U26TdBBNT56HFXWAb4ktFyWBTuCAnwdajecTL4ss2BhciRviG',
micro_index: 0,
micro_time: 1721213471890,
signatures: [
'sg_E1Ezn9EMsxTZz7a93Zc5kjXkS1t3WqFbr3X8DqqjdXXfXD9Xy6DZQpjB2rHfcoZ3ySZ1FHh9bzMjfQfdA9mRJJ4yeYdfN',
'sg_WNvkq9RewEjZDrDLqXMUoyBd8pGzqAuyaDfG3bQAfGx4tF6smTLyYnFWmtY8SrJRnEHbriDUm836DSJSkMjiijLKBsSzo',
],
tx: {
amount: 5000000000000000000,
fee: 17040000000000,
nonce: 37016,
payload: 'ba_RmF1Y2V0IFR4tYtyuw==',
recipient_id: 'ak_DtJrupsqqByQag76NrxAAimmkYJMk7on7z3xktdZpdkmxKQak',
sender_id: 'ak_2iBPH7HUz3cSDVEUWiHg76MZJ6tZooVNBmmxcgVK6VV8KAE688',
amount: 1000000000000000000,
fee: 16820000000000,
nonce: 1,
payload: 'ba_Xfbg4g==',
recipient_id: 'ak_2Fh6StA76AKdy8qsGdkEfkQyVmAYc2XE1irWRnDgXKhmBLKoXg',
sender_id: 'ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E',
ttl: 4,
type: 'SpendTx',
version: 1,
},
Expand All @@ -143,6 +150,17 @@ describe('Middleware API', () => {
next: null,
prev: null,
};
assertNotNull(expectedRes.data);
expectedRes.data.forEach((item, idx) => {
assertNotNull(res.data);
item.blockHash = res.data[idx].blockHash;
item.blockTime = res.data[idx].blockTime;
['block_hash', 'micro_time', 'signatures', 'encoded_tx'].forEach((key) => {
assertNotNull(res.data);
if (res.data[idx].payload[key] == null) return;
item.payload[key] = res.data[idx].payload[key];
});
});
expect(res).to.be.eql(expectedRes);
});
});
Loading

0 comments on commit 88409c2

Please sign in to comment.