3 const assert = require('assert');
4 const fixtureLoader = require('gitter-web-test-utils/lib/test-fixtures');
6 const detectEthereumSpam = require('../lib/detect-ethereum-spam');
8 const MESSAGE_FIXTURE_MAP = {
9 '0x352EF597BC9C551497B3686eA3403cA53d105524': true,
10 '0xBe0DC5EDC04eFAc1592f212190167fA59A7C5586': true,
11 '0x4D8022B0878eDbFA6E3A3dB934DC587eE8053F86': true,
12 '0x5a38f4c89a8becaed0d0d03b6d7319f31ebce6c6': true,
13 '0x5B47bD0f5E07c590a70CD4D12d709C88845e2f0f': true,
14 'Send 3ETH 0x31999626cDc00c877530b64c209707Ad0ED556fE': false,
15 'sent 5 ETH 0x519040d1Daa5Ab78b9C87F825A38b5464Cd3828d': false,
16 'I tried to send 5 ETHER from my wallet, transaction will be created but will not confirm': false,
17 'After doing "migrate", I got my ETH token address 0xfb88de099e13c3ed21f80a7a1e49f8caecf10df6': false,
18 'Beth experienced a BSOD at memory address 0x31999626cDc00c877530b64c209707Ad0ED556fE': false
21 describe('detect-ethereum-spam', () => {
22 const fixture = fixtureLoader.setup({
26 describe('in a dirty group', () => {
27 Object.keys(MESSAGE_FIXTURE_MAP).forEach(text => {
28 const expectedIsSpamming = MESSAGE_FIXTURE_MAP[text];
30 it(`${expectedIsSpamming}: ${text}`, async () => {
31 const isSpamming = await detectEthereumSpam({
32 groupId: 'dirty-group',
33 dirtyGroupList: ['dirty-group'],
38 assert.strictEqual(isSpamming, expectedIsSpamming);
43 describe('in a "clean" group that we don\'t need to clean', () => {
44 Object.keys(MESSAGE_FIXTURE_MAP).forEach(text => {
45 const expectedIsSpamming = false;
47 it(`${expectedIsSpamming}: ${text}`, async () => {
48 const isSpamming = await detectEthereumSpam({
49 groupId: 'good-group',
50 groupIdBlackList: ['dirty-group'],
55 assert.strictEqual(isSpamming, expectedIsSpamming);