Skip to content

Commit

Permalink
Merge pull request #145 from bancorprotocol/144-fix-manager-tests
Browse files Browse the repository at this point in the history
Update event_test_data.json
  • Loading branch information
mikewcasale authored Sep 20, 2023
2 parents 03286c6 + 4056dd3 commit 32f8c0e
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 96 deletions.
165 changes: 93 additions & 72 deletions fastlane_bot/data/event_test_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,38 @@
"blockHash": "0xc4c2ffbf7e0a2b94721eee92a8acaed343d2f332bcd83bf0b66d63b826d78cf6",
"blockNumber": 17613637
},
"carbon_v1_event_create_for_update": {
"args": {
"owner": "0xDdD6516Ed7e9B2dEfb2e1aE50379943cC9eE2b73",
"token0": "0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C",
"token1": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"id": 2381976568446569244243622252022377480690,
"order0": [
0,
0,
0,
0
],
"order1": [
0,
0,
0,
0
]
},
"event": "StrategyCreated",
"logIndex": 131,
"transactionIndex": 88,
"transactionHash": "0x2e147a21fa45c76c9fa0231a52629b71dcc7293747c4fb1c96f7e0ce5f058c9a",
"address": "0xC537e898CD774e2dCBa3B14Ea6f34C93d5eA45e1",
"blockHash": "0x452c70bd1d52430fbc2327425f1ad3e59a3e1ff5f0a84d4a6aaf757c4d3a942f",
"blockNumber": 18176438
},
"carbon_v1_event_update": {
"args": {
"id": 340282366920938463463374607431768211699,
"token0": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"token1": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"id": 2381976568446569244243622252022377480690,
"token0": "0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C",
"token1": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"order0": [
1020304,
30000000000000000000,
Expand All @@ -85,107 +112,80 @@
"blockHash": "0x5d9484d50eaf69a1c5715e0a52b58a3d362bce09ff5517bc43ff6fe2cfa2965f",
"blockNumber": 17613884
},
"carbon_v1_event_delete": {
"args": {
"owner": "0x1f660f4C9e0c833520eEfE7e207249B3Fa7DB92F",
"token0": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"token1": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"id": 1701411834604692317316873037158841057369,
"order0": [
250000000000000000,
250000000000000000,
0,
4414201427359729
],
"order1": [
446009466,
446009466,
0,
10901478971
]
},
"event": "StrategyDeleted",
"logIndex": 454,
"transactionIndex": 158,
"transactionHash": "0x6e2ee77bb751644a1f0f693f4e7b2547be495d5473b378b36b58a8c72ba92421",
"address": "0xC537e898CD774e2dCBa3B14Ea6f34C93d5eA45e1",
"blockHash": "0x898cd767e25952ae0a2de3714efb6406846702815bb8f77cdbea5824a0e1d6ff",
"blockNumber": 17614185
},
"carbon_v1_event_create": {
"args": {
"owner": "0x11B1785D9Ac81480c03210e89F1508c8c115888E",
"token0": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"owner": "0xDdD6516Ed7e9B2dEfb2e1aE50379943cC9eE2b73",
"token0": "0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C",
"token1": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"id": 1701411834604692317316873037158841057529,
"id": 2381976568446569244243622252022377480690,
"order0": [
1221000000000000000000,
1221000000000000000000,
0,
0,
3041871764463936,
4414201427359729
6111054486652827
],
"order1": [
383896420,
383896420,
235894417,
11805182669
464234783,
464234783,
0,
173512828
]
},
"event": "StrategyCreated",
"logIndex": 227,
"transactionIndex": 89,
"transactionHash": "0x8f6ee587bd72cfa8a1a3faf165825c528df8a587827f182f099deed71c998b75",
"logIndex": 131,
"transactionIndex": 88,
"transactionHash": "0x2e147a21fa45c76c9fa0231a52629b71dcc7293747c4fb1c96f7e0ce5f058c9a",
"address": "0xC537e898CD774e2dCBa3B14Ea6f34C93d5eA45e1",
"blockHash": "0x7fcc4a119651992df2fd94d7d8c33f895c2076480badf5ccc6b08e78e053f8fe",
"blockNumber": 17599450
"blockHash": "0x452c70bd1d52430fbc2327425f1ad3e59a3e1ff5f0a84d4a6aaf757c4d3a942f",
"blockNumber": 18176438
},
"carbon_v1_event_create_for_update": {
"carbon_v1_event_create_for_delete": {
"args": {
"owner": "0x11B1785D9Ac81480c03210e89F1508c8c115888E",
"id": 340282366920938463463374607431768211699,
"token0": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"token1": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"owner": "0xDdD6516Ed7e9B2dEfb2e1aE50379943cC9eE2b73",
"token0": "0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C",
"token1": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"id": 2381976568446569244243622252022377480690,
"order0": [
1221000000000000000000,
1221000000000000000000,
0,
0,
0,
0
6111054486652827
],
"order1": [
464234783,
464234783,
0,
0,
0,
0
173512828
]
},
"event": "StrategyCreated",
"logIndex": 378,
"transactionIndex": 157,
"transactionHash": "0x78aeca0f0f6263a93b5f6208241e302a1994ad614968fa161ca072727b9a5f4b",
"logIndex": 131,
"transactionIndex": 88,
"transactionHash": "0x2e147a21fa45c76c9fa0231a52629b71dcc7293747c4fb1c96f7e0ce5f058c9a",
"address": "0xC537e898CD774e2dCBa3B14Ea6f34C93d5eA45e1",
"blockHash": "0x5d9484d50eaf69a1c5715e0a52b58a3d362bce09ff5517bc43ff6fe2cfa2965f",
"blockNumber": 17613884
"blockHash": "0x452c70bd1d52430fbc2327425f1ad3e59a3e1ff5f0a84d4a6aaf757c4d3a942f",
"blockNumber": 18176438
},
"carbon_v1_event_create_for_delete": {
"carbon_v1_event_delete": {
"args": {
"owner": "0x1f660f4C9e0c833520eEfE7e207249B3Fa7DB92F",
"token0": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"owner": "0xDdD6516Ed7e9B2dEfb2e1aE50379943cC9eE2b73",
"token0": "0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C",
"token1": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"id": 1701411834604692317316873037158841057369,
"id": 2381976568446569244243622252022377480690,
"order0": [
250000000000000000,
250000000000000000,
1221000000000000000000,
1221000000000000000000,
0,
4414201427359729
6111054486652827
],
"order1": [
446009466,
446009466,
464234783,
464234783,
0,
10901478971
173512828
]
},
"event": "StrategyCreated",
"event": "StrategyDeleted",
"logIndex": 454,
"transactionIndex": 158,
"transactionHash": "0x6e2ee77bb751644a1f0f693f4e7b2547be495d5473b378b36b58a8c72ba92421",
Expand Down Expand Up @@ -232,5 +232,26 @@
"address": "0xADd45B18153382D69AB5A13c44d1782B8f3aDEEc",
"blockHash": "0x45f34d791644169219b806ebdf60341fb5e62e4ed49e9da225e34d82e17f1f8b",
"blockNumber": 18005932
},
"bancor_pol_trading_enabled_event": {
"args": {
"token": "0x86772b1409b61c639EaAc9Ba0AcfBb6E238e5F83",
"price": [11371711775732, 1000000000000000000]
},
"event": "TradingEnabled", "logIndex": 0, "transactionIndex": 0, "transactionHash": "0x47ca9288a8924d1728cbb1551b7a93ba92fb1cbbff317b2c95a89124b3864faf", "address": "0xD06146D292F9651C1D7cf54A3162791DFc2bEf46", "blockHash": "0x2f6d52f57be7062bf09a2a714e86c87e00b31d63133b1529e9eb304aa1539621", "blockNumber": 18137602
},
"bancor_pol_token_traded_event": {
"args": {
"caller": "0x41Eeba3355d7D6FF628B7982F3F9D055c39488cB",
"token": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"amount": 4913114339236985831, "ethReceived": 2766999999999999
},
"event": "TokenTraded",
"logIndex": 2,
"transactionIndex": 0,
"transactionHash": "0xaa7bc078cb2e785dc5df61b5d429190539dca47bba3e263683e0e90356805906",
"address": "0xD06146D292F9651C1D7cf54A3162791DFc2bEf46",
"blockHash": "0x3ce386e131db4763ec18cd67a7dedabd68b0b693400b33f98dfb8ad441085004",
"blockNumber": 18137708
}
}
3 changes: 3 additions & 0 deletions fastlane_bot/tests/nbtest/test_036_Manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ def test_test_update_from_event_carbon_v1_update():
# ------------------------------------------------------------

# +
event_create_for_update = event_data['carbon_v1_event_create_for_update']
event = event_data['carbon_v1_event_update']

manager.update_from_event(event_create_for_update)
assert event['args']['order0'][0] != [pool['y_0'] for pool in manager.pool_data if pool['cid'] == event['args']['id']][0]

manager.update_from_event(event)
Expand Down
62 changes: 39 additions & 23 deletions resources/NBTest/NBTest_036_Manager.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
"id": "6b800d59",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-13T04:47:56.521013Z",
"start_time": "2023-07-13T04:47:56.487042Z"
"end_time": "2023-09-20T14:03:06.090221Z",
"start_time": "2023-09-20T14:03:02.984869Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ConstantProductCurve v2.14 (23/May/2023)\n",
"ConstantProductCurve v3.2 (15/Sep/2023)\n",
"CarbonBot v3-b2.2 (20/June/2023)\n",
"UniswapV2 v0.0.1 (2023-07-03)\n",
"UniswapV3 v0.0.1 (2023-07-03)\n",
"SushiswapV2 v0.0.1 (2023-07-03)\n",
"CarbonV1 v0.0.1 (2023-07-03)\n",
"BancorV3 v0.0.1 (2023-07-03)\n",
"UniswapV2 v0.0.2 (2023-08-27)\n",
"UniswapV3 v0.0.2 (2023-08-27)\n",
"SushiswapV2 v0.0.2 (2023-08-27)\n",
"CarbonV1 v0.0.2 (2023-08-27)\n",
"BancorV3 v0.0.2 (2023-08-27)\n",
"imported m, np, pd, plt, os, sys, decimal; defined iseq, raises, require\n",
"Version = 3-b2.2 [requirements >= 3.0 is met]\n"
]
Expand Down Expand Up @@ -68,8 +68,8 @@
"id": "80ddef38",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-13T04:47:56.527256Z",
"start_time": "2023-07-13T04:47:56.493598Z"
"end_time": "2023-09-20T14:03:06.128079Z",
"start_time": "2023-09-20T14:03:06.090785Z"
}
},
"outputs": [],
Expand All @@ -89,11 +89,24 @@
"id": "7919999a",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-13T04:47:57.071520Z",
"start_time": "2023-07-13T04:47:56.526210Z"
"end_time": "2023-09-20T14:03:08.151919Z",
"start_time": "2023-09-20T14:03:06.113589Z"
}
},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2023-09-20 07:03:06,113 [fastlane:INFO] - \n",
"2023-09-20 07:03:06,113 [fastlane:INFO] - **********************************************\n",
"2023-09-20 07:03:06,114 [fastlane:INFO] - The logging path is set to: logs/20230920-070306/bot.log\n",
"2023-09-20 07:03:06,114 [fastlane:INFO] - **********************************************\n",
"2023-09-20 07:03:06,114 [fastlane:INFO] - \n",
"2023-09-20 07:03:07,076 [fastlane:INFO] - Retrieved 169 carbon pairs from contract\n"
]
}
],
"source": [
"\n",
"# Create mock instances for all required parameters\n",
Expand All @@ -117,8 +130,8 @@
"id": "584c8056",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-13T04:47:57.078106Z",
"start_time": "2023-07-13T04:47:57.076377Z"
"end_time": "2023-09-20T14:03:08.158339Z",
"start_time": "2023-09-20T14:03:08.156731Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -147,8 +160,8 @@
"id": "2baa6f73",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-13T04:47:57.084015Z",
"start_time": "2023-07-13T04:47:57.082263Z"
"end_time": "2023-09-20T14:03:08.164064Z",
"start_time": "2023-09-20T14:03:08.162595Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -183,13 +196,16 @@
"id": "71334cab",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-13T04:47:57.089037Z",
"start_time": "2023-07-13T04:47:57.086893Z"
"end_time": "2023-09-20T14:03:08.800682Z",
"start_time": "2023-09-20T14:03:08.166659Z"
}
},
"outputs": [],
"source": [
"event_create_for_update = event_data['carbon_v1_event_create_for_update']\n",
"event = event_data['carbon_v1_event_update']\n",
"\n",
"manager.update_from_event(event_create_for_update)\n",
"assert event['args']['order0'][0] != [pool['y_0'] for pool in manager.pool_data if pool['cid'] == event['args']['id']][0]\n",
"\n",
"manager.update_from_event(event)\n",
Expand All @@ -211,8 +227,8 @@
"id": "71d67e1c",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-13T04:47:57.336085Z",
"start_time": "2023-07-13T04:47:57.092889Z"
"end_time": "2023-09-20T14:03:08.820959Z",
"start_time": "2023-09-20T14:03:08.805835Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -240,8 +256,8 @@
"id": "452029c9",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-13T04:47:57.572478Z",
"start_time": "2023-07-13T04:47:57.341059Z"
"end_time": "2023-09-20T14:03:08.838302Z",
"start_time": "2023-09-20T14:03:08.825262Z"
}
},
"outputs": [],
Expand Down
5 changes: 4 additions & 1 deletion resources/NBTest/NBTest_036_Manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.13.1
# jupytext_version: 1.15.2
# kernelspec:
# display_name: Python 3
# language: python
Expand Down Expand Up @@ -95,7 +95,10 @@
# ## test_update_from_event_carbon_v1_update

# +
event_create_for_update = event_data['carbon_v1_event_create_for_update']
event = event_data['carbon_v1_event_update']

manager.update_from_event(event_create_for_update)
assert event['args']['order0'][0] != [pool['y_0'] for pool in manager.pool_data if pool['cid'] == event['args']['id']][0]

manager.update_from_event(event)
Expand Down

0 comments on commit 32f8c0e

Please sign in to comment.