Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
slux83 committed Feb 14, 2024
2 parents 3103e88 + 09b92c8 commit ea7a811
Show file tree
Hide file tree
Showing 14 changed files with 1,468 additions and 134 deletions.
8 changes: 1 addition & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.devpool</groupId>
<artifactId>thoth-bot</artifactId>
<version>1.5.2</version>
<version>1.5.3</version>
<name>Thoth Bot Cardano</name>
<description>A Telegram Bot for the Cardano blockchain that monitors wallet activities and notifies users about TXs,
etc.
Expand Down Expand Up @@ -66,12 +66,6 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.pengrad</groupId>
<artifactId>java-telegram-bot-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DB_PASSWORD="postgres"
DB_HOST="localhost"
DB_PORT="5432"
DB_NAME="thoth"
THOTH_VERSION="1.5.2"
THOTH_VERSION="1.5.3"
LOGS_FOLDER="${DIR}/logs"
ADMIN_USERNAME="CHANGE_ME"

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class HelpCmd implements IBotCommand {
* Some global constants
*/
public static final Map<String, String> CONSTANTS = Map.of(
"$thoth.version", "1.5.2",
"$thoth.version", "1.5.3",
"$donation.handle", "$thoth-bot",
"$url", "https://github.com/DevStakePool/thoth-bot");

Expand Down
81 changes: 60 additions & 21 deletions src/test/java/com/devpool/thothBot/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public void userCommandUnsubscribeTest() throws Exception {
public void scheduledNotificationsTest() throws Exception {
Mockito.verify(this.telegramFacadeMock,
Mockito.timeout(60 * 1000)
.times(79))
.times(80))
.sendMessageTo(this.chatIdArgCaptor.capture(), this.messageArgCaptor.capture());

List<User> allUsers = this.userDao.getUsers();
Expand All @@ -287,25 +287,28 @@ public void scheduledNotificationsTest() throws Exception {
//Expected transactions for addresses addr1qy2jt0qpqz2z2z9zx5w4xemekkce7yderz53kjue53lpqv90lkfa9sgrfjuz6uvt4uqtrqhl2kj0a9lnr9ndzutx32gqleeckv: 5
//Expected transactions for addresses addr1wxwrp3hhg8xdddx7ecg6el2s2dj6h2c5g582yg2yxhupyns8feg4m: 58
//Total expected transactions for accounts+addresses 214
// Numbers below differs from this due to the data added from issues

List<String> allMessages = messageArgCaptor.getAllValues();

Assertions.assertEquals(8, countTxForAddress(allMessages, "stake1u8lffpd48ss4f2pe0rhhj4n2edkgwl38scl09f9f43y0azcnhxhwr"));
Assertions.assertEquals(87, countTxForAddress(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32"));
Assertions.assertEquals(88, countTxForAddress(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32"));
Assertions.assertEquals(41, countTxForAddress(allMessages, "stake1u9ttjzthgk2y7x55c9f363a6vpcthv0ukl2d5mhtxvv4kusv5fmtz"));
Assertions.assertEquals(16, countTxForAddress(allMessages, "stake1uxpdrerp9wrxunfh6ukyv5267j70fzxgw0fr3z8zeac5vyqhf9jhy"));
Assertions.assertEquals(1, countTxForAddress(allMessages, "stake1u8656c05pay70xtpcwp3dqgu4jwullv6qu9e50ykn59lz7g7vzwt7"));
Assertions.assertEquals(2, countTxForAddress(allMessages, "stake1u8656c05pay70xtpcwp3dqgu4jwullv6qu9e50ykn59lz7g7vzwt7"));
Assertions.assertEquals(5, countTxForAddress(allMessages, "addr1qy2jt0qpqz2z2z9zx5w4xemekkce7yderz53kjue53lpqv90lkfa9sgrfjuz6uvt4uqtrqhl2kj0a9lnr9ndzutx32gqleeckv"));
Assertions.assertEquals(58, countTxForAddress(allMessages, "addr1wxwrp3hhg8xdddx7ecg6el2s2dj6h2c5g582yg2yxhupyns8feg4m"));
Assertions.assertEquals(4, allMessages.stream().filter(m -> m.contains("reward(s)")).count());
// TX internal, empty
String message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32",
"3af819e5583709c9e7b5b84614c60015b9bf10deb2b20756118cba707e531e53");
Assertions.assertTrue(message.contains("Fee 0.18"));
Assertions.assertTrue(message.contains("Internal Funds"));

// TX internal, pool delegation
message = retrieveMessageByString(allMessages, "stake1u8lffpd48ss4f2pe0rhhj4n2edkgwl38scl09f9f43y0azcnhxhwr",
"3f31f56afbfa4c4bdd7c33d1f1d4ae0cedece2fa2bfb2934b914ea5e0dfb0142");
Assertions.assertTrue(message.contains("Internal Funds"));
Assertions.assertTrue(message.contains("[DEV]"));

// TX sent funds, with message
Expand All @@ -316,17 +319,21 @@ public void scheduledNotificationsTest() throws Exception {
Assertions.assertTrue(message.contains("Sent -55.00"));

// TX catalyst new airdrop method
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32", "19c57aec14b9cefd4b1025c09c64bf857a4d2e3c0ee184d62b2eca8dfceb929b");
Assertions.assertTrue(message.contains("59.54"));
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32",
"19c57aec14b9cefd4b1025c09c64bf857a4d2e3c0ee184d62b2eca8dfceb929b");
Assertions.assertTrue(message.contains("Received 59.54"));
Assertions.assertTrue(message.contains("Fee 0.87"));
Assertions.assertTrue(message.contains("Fund10 Voter rewards"));

// TX received funds, 1 token
message = retrieveMessageByString(allMessages, "addr1wxwrp3hhg8xdddx7ecg6el2s2dj6h2c5g582yg2yxhupyns8feg4m", "9f8067d6565c5e189551b9ca820ff27ec87dc955420ab9d8a6ce4107d5d27743");
message = retrieveMessageByString(allMessages, "addr1wxwrp3hhg8xdddx7ecg6el2s2dj6h2c5g582yg2yxhupyns8feg4m",
"9f8067d6565c5e189551b9ca820ff27ec87dc955420ab9d8a6ce4107d5d27743");
Assertions.assertTrue(message.contains("wide open 1"));
Assertions.assertTrue(message.contains("Received 1.04"));

// TX received funds, with message
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32", "773b01dfcd7a0398a8576129410084c8797906b913bdf6437289daebb672f085");
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32",
"773b01dfcd7a0398a8576129410084c8797906b913bdf6437289daebb672f085");
Assertions.assertTrue(message.contains("DEV Pool patron rewards for epoch 377"));
Assertions.assertTrue(message.contains("Sent -55.00"));
Assertions.assertTrue(message.contains("Fee 0.20"));
Expand All @@ -341,32 +348,36 @@ public void scheduledNotificationsTest() throws Exception {
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32", "3e2e4a2b7d78bc5994773805f1376d790c8169b63297d50ef4842e22aafb1f29");
Assertions.assertTrue(message.contains("Fee 0.39"));
Assertions.assertTrue(message.contains("Sent -5.57"));
Assertions.assertTrue(message.contains("Cardano Summit 2023 NFT 1939 1"));
Assertions.assertTrue(message.contains("Cardano Summit 2023 NFT 3022 1"));
Assertions.assertTrue(message.contains("Cardano Summit 2023 NFT 2884 1"));
Assertions.assertTrue(message.contains("Cardano Summit 2023 NFT 5802 1"));
Assertions.assertTrue(message.contains("Cardano Summit 2023 NFT 1939 -1"));
Assertions.assertTrue(message.contains("Cardano Summit 2023 NFT 3022 -1"));
Assertions.assertTrue(message.contains("Cardano Summit 2023 NFT 2884 -1"));
Assertions.assertTrue(message.contains("Cardano Summit 2023 NFT 5802 -1"));

// TX sent funds, jpeg store contract
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32", "e9f577499a692fc07491cd7de013ea2c3b3a37b3df616aeb39f807ed5ced8d24");
Assertions.assertTrue(message.contains("Fee 0.46"));
Assertions.assertTrue(message.contains("Sent -13.61"));
Assertions.assertTrue(message.contains("JpegStore"));
Assertions.assertTrue(message.contains("Cardano Summit 2023 NFT 1501 1"));

// TX received funds, jpeg store multiple (2) contracts
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32", "b6170c1c89f91bb5f76c0810889ea110f34b63e7fde25b37abe269256ac2f45a");
Assertions.assertTrue(message.contains("Fee 1.11"));
Assertions.assertTrue(message.contains("Received 18.00"));
message = message.substring(message.indexOf("b6170c1c89f91bb5f76c0810889ea110f34b63e7fde25b37abe269256ac2f45a"));
Assertions.assertEquals(2, message.split("JpegStore").length - 1);
Assertions.assertEquals(2, message.split("\\[JpegStore]").length - 1);

// TX with ada handle
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32", "a6abf48aad975fac80416ce79f9a7969fe05e13a37eb8be1e917d5d84d6044");
Assertions.assertTrue(message.contains("$alessio.dev"));

// TX sent funds and tokens (with token hash)
message = retrieveMessageByString(allMessages, "stake1u9ttjzthgk2y7x55c9f363a6vpcthv0ukl2d5mhtxvv4kusv5fmtz", "69c2f2f96305b5d1eb46eb5180f9dfb0409c54919d2463ae61becf34570e504a");
Assertions.assertTrue(message.contains("...9d660cf6a2 498,221,110"));
Assertions.assertTrue(message.contains("hvADA 2,528,098"));
// TX sent funds and received tokens
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32",
"2249e6906a7fba98247f22939ee102eb0ceeea207d3014a3b2cbd4944dd21513");
Assertions.assertTrue(message.contains("Received 1.09"));
Assertions.assertTrue(message.contains("Fee 0.30"));
Assertions.assertTrue(message.contains("Received Funds and Received Tokens"));
Assertions.assertTrue(message.contains("Cardano Summit 2023 NFT 6808 1"));

// Pool operator rewards
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32",
Expand All @@ -393,7 +404,7 @@ public void scheduledNotificationsTest() throws Exception {
// TX received funds, received tokens
message = retrieveMessageByString(allMessages, "stake1uxpdrerp9wrxunfh6ukyv5267j70fzxgw0fr3z8zeac5vyqhf9jhy",
"083e302d0c5d11c07fa642c18df8fa290632c24157c676a754a5a763605ebe26");
Assertions.assertTrue(message.contains("MACH 3,947.00"));
Assertions.assertTrue(message.contains("MACH 3,947"));
Assertions.assertTrue(message.contains("1.73"));
Assertions.assertTrue(message.contains("Received Funds and Received Tokens"));
Assertions.assertFalse(message.contains("[JpegStore]"));
Expand All @@ -412,22 +423,50 @@ public void scheduledNotificationsTest() throws Exception {
Assertions.assertFalse(message.contains("Withdrawal"));
Assertions.assertTrue(message.contains("Received 300"));

// TX with no input but just output (simple received NFT + funds from a friend)
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32",
"2c122a05b4cc3121e2e7225374ae8cfe74d947aa8169264878d2fd1dc0a40702");
Assertions.assertTrue(message.contains("Received Funds and Received Tokens"));
Assertions.assertTrue(message.contains("Fee 0.17"));
Assertions.assertTrue(message.contains("Received 1.19"));
Assertions.assertTrue(message.contains("CARDANO PETS-0026 1"));



// Issue #43
message = retrieveMessageByString(allMessages, "stake1u8656c05pay70xtpcwp3dqgu4jwullv6qu9e50ykn59lz7g7vzwt7",
"f5401d48ac42a1199c8fbb214e63e4f350ee5a4f099ff460ca7f8f7bdcfabd4c");

Assertions.assertTrue(message.contains("Sent Funds and Tokens"));
Assertions.assertTrue(message.contains("Djed USD 746.00"));
Assertions.assertTrue(message.contains("Sent Funds and Sent Tokens"));
Assertions.assertTrue(message.contains("Djed USD -746.00"));
Assertions.assertTrue(message.contains("-1.19"));
Assertions.assertFalse(message.contains("iETH"));

// Issue #39
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32",
"0a416d362c9e1884292c4160254a7a8afc4b3921c783114d3d7574a8087ba3da");
Assertions.assertTrue(message.contains("Sent Funds and Tokens"));
Assertions.assertTrue(message.contains("Sent Funds and Sent Tokens"));
Assertions.assertTrue(message.contains("Dexhunter Trade"));
Assertions.assertTrue(message.contains("Empowa 3,025"));
Assertions.assertTrue(message.contains("Empowa -3,025.28"));
Assertions.assertTrue(message.contains("Sent -14"));
Assertions.assertTrue(message.contains("Fee 0.25"));

// Issue #47
message = retrieveMessageByString(allMessages, "stake1u8656c05pay70xtpcwp3dqgu4jwullv6qu9e50ykn59lz7g7vzwt7",
"779133d969dc88440d18741dc17e536b8b1b21ac0fdb431f4d2850f028839d81");
Assertions.assertTrue(message.contains("Sent Funds, Sent and Received Tokens"));
Assertions.assertTrue(message.contains("Fee 0.32"));
Assertions.assertTrue(message.contains("Sent -2.00"));
Assertions.assertTrue(message.contains("iUSD -2,369.08"));
Assertions.assertTrue(message.contains("qiUSD 116,002.71"));

// Issue #47 - received funds and sent tokens
message = retrieveMessageByString(allMessages, "stake1u8uekde7k8x8n9lh0zjnhymz66sqdpa0ms02z8cshajptac0d3j32",
"24188c3d4aa6efad2c1250705a9ee5f8acd8c59cf9e4eebf9541477af7b10d15");
Assertions.assertTrue(message.contains("Received Funds and Sent Tokens"));
Assertions.assertTrue(message.contains("Received 16.07"));
Assertions.assertTrue(message.contains("Fee 0.40"));
Assertions.assertTrue(message.contains("MalTheTrader12416 -1"));

// check for null handles
for (String m : allMessages) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"policy_id": "1cc1aceaf5c7df55e270864a60600b9f52383fe418164574ffdeeed0",
"asset_name": "",
"asset_name_ascii": "",
"fingerprint": "asset1ajv4exyhqq8zuxvpvnqcj5vtxks0xhqvkghmwq",
"minting_tx_hash": "9d810993d5b536496dbb5c3733bf4eb6c5acdbad6bdfb6b4b84c33315de66d7e",
"total_supply": "16",
"mint_cnt": 1,
"burn_cnt": 0,
"creation_time": 1685404800,
"minting_tx_metadata": null,
"token_registry_metadata": {
"url": "",
"logo": "",
"name": "Liqwid iUSD Action",
"ticker": "iUSDAXN",
"decimals": 0,
"description": "Utility token for Liqwid iUSD market"
},
"cip68_metadata": null
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"policy_id": "416109f322b43051b80e83075b4baa8c5af14c88acaca47d5c251820",
"asset_name": "",
"asset_name_ascii": "",
"fingerprint": "asset1wjw72ah0ph7u60a7qd02xyw4mk0995wvhglwxa",
"minting_tx_hash": "9d810993d5b536496dbb5c3733bf4eb6c5acdbad6bdfb6b4b84c33315de66d7e",
"total_supply": "1",
"mint_cnt": 1,
"burn_cnt": 0,
"creation_time": 1685404800,
"minting_tx_metadata": null,
"token_registry_metadata": {
"url": "",
"logo": "",
"name": "Liqwid iUSD MarketState",
"ticker": "iUSDST",
"decimals": 0,
"description": "Utility token for Liqwid iUSD market"
},
"cip68_metadata": null
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"policy_id": "f967b3a86a9880c876851fa64b352a4d3887d6436904190b698f232e",
"asset_name": "",
"asset_name_ascii": "",
"fingerprint": "asset100qa7m200hgycvezpyyqxngz7c9606gne6etm6",
"minting_tx_hash": "9d810993d5b536496dbb5c3733bf4eb6c5acdbad6bdfb6b4b84c33315de66d7e",
"total_supply": "1",
"mint_cnt": 1,
"burn_cnt": 0,
"creation_time": 1685404800,
"minting_tx_metadata": null,
"token_registry_metadata": {
"url": "",
"logo": "",
"name": "Liqwid iUSD MarketParams",
"ticker": "iUSDPRM",
"decimals": 0,
"description": "Utility token for Liqwid iUSD market"
},
"cip68_metadata": null
}
]
17 changes: 16 additions & 1 deletion src/test/resources/test-data/fetch_issues_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,22 @@ curl -s -X POST "https://api.koios.rest/api/v1/tx_info" \
-H "content-type: application/json" \
-d '{"_tx_hashes":["0a416d362c9e1884292c4160254a7a8afc4b3921c783114d3d7574a8087ba3da"]}' | jq > issues/39_txs_info.json

# Issue 47
curl -s -X POST "https://api.koios.rest/api/v1/tx_info" \
-H "accept: application/json"\
-H "content-type: application/json" \
-d '{"_tx_hashes":["779133d969dc88440d18741dc17e536b8b1b21ac0fdb431f4d2850f028839d81"]}' | jq > issues/47_txs_info.json

# Issue 48
curl -s -X POST "https://api.koios.rest/api/v1/tx_info" \
-H "accept: application/json"\
-H "content-type: application/json" \
-d '{"_tx_hashes":["24188c3d4aa6efad2c1250705a9ee5f8acd8c59cf9e4eebf9541477af7b10d15"]}' | jq > issues/48_txs_info.json


# Fetching assets
echo "Fetching all assets in all TXs"
download_assets "issues/43_txs_info.json"
download_assets "issues/39_txs_info.json"
download_assets "issues/39_txs_info.json"
download_assets "issues/47_txs_info.json"
download_assets "issues/48_txs_info.json"
4 changes: 2 additions & 2 deletions src/test/resources/test-data/issues/43_account_utxos.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
{
"tx_hash": "f5401d48ac42a1199c8fbb214e63e4f350ee5a4f099ff460ca7f8f7bdcfabd4c",
"tx_index": 3,
"address": "addr1q8euez0khcvekzl2h56tyzqtwc9gjghclz2ccx4edwj4lm84f4slgr6fu7vkrsurz6q3etyael7e5pctng7fd8gt79us0gkzmt",
"address": "whatever",
"value": "10059221",
"stake_address": "stake1u8656c05pay70xtpcwp3dqgu4jwullv6qu9e50ykn59lz7g7vzwt7",
"payment_cred": "f3cc89f6be199b0beabd34b2080b760a8922f8f8958c1ab96ba55fec",
"payment_cred": "whatever",
"epoch_no": 1,
"block_height": 1,
"block_time": 1,
Expand Down
18 changes: 18 additions & 0 deletions src/test/resources/test-data/issues/47_account_utxos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"tx_hash": "779133d969dc88440d18741dc17e536b8b1b21ac0fdb431f4d2850f028839d81",
"tx_index": 3,
"address": "whatever",
"value": "10059221",
"stake_address": "stake1u8656c05pay70xtpcwp3dqgu4jwullv6qu9e50ykn59lz7g7vzwt7",
"payment_cred": "whatever",
"epoch_no": 1,
"block_height": 1,
"block_time": 1,
"datum_hash": null,
"inline_datum": null,
"reference_script": null,
"asset_list": null,
"is_spent": false
}
]
Loading

0 comments on commit ea7a811

Please sign in to comment.