Fix getAddress tests to use the updated comment format with md link

This commit is contained in:
Pedro Pombeiro 2018-03-21 10:40:29 +01:00
parent c418a5c6b8
commit b0a8db2102
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647
3 changed files with 12 additions and 5 deletions

View File

@ -58,9 +58,13 @@ function hasAddress (req) {
function getAddress (req) { function getAddress (req) {
const commentBody = req.body.comment.body const commentBody = req.body.comment.body
const index = commentBody.search(contractAddressString) + contractAddressString.length + 1 const index = commentBody.search(contractAddressString)
console.log("address: ", commentBody.substring(index, index + 42)) if (index === -1) {
return commentBody.substring(index, index + 42) return undefined
}
const addressIndex = index + contractAddressString.length + 1
console.log('address: ', commentBody.substring(addressIndex, addressIndex + 42))
return commentBody.substring(addressIndex, addressIndex + 42)
} }
async function getLabel (req) { async function getLabel (req) {

View File

@ -6,7 +6,7 @@
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",
"debug": "node --inspect-brk index.js", "debug": "node --inspect-brk index.js",
"test": "./node_modules/mocha/bin/mocha" "test": "./node_modules/mocha/bin/mocha --timeout 5s"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",

View File

@ -4,7 +4,7 @@ const config = require('../config')
const bot = require('../bot') const bot = require('../bot')
// status-open-bounty comment from https://github.com/status-im/autobounty/issues/1 // status-open-bounty comment from https://github.com/status-im/autobounty/issues/1
const sobComment = 'Current balance: 0.000000 ETH\nTokens: SNT: 2500.00 ANT: 25.00\nContract address: 0x3645fe42b1a744ad98cc032c22472388806f86f9\nNetwork: Mainnet\n To claim this bounty sign up at https://openbounty.status.im and make sure to update your Ethereum address in My Payment Details so that the bounty is correctly allocated.\nTo fund it, send ETH or ERC20/ERC223 tokens to the contract address.' const sobComment = 'Current balance: 0.000000 ETH\nTokens: SNT: 2500.00 ANT: 25.00\nContract address: [0x3645fe42b1a744ad98cc032c22472388806f86f9](https://etherscan.io/address/0x3645fe42b1a744ad98cc032c22472388806f86f9)\nNetwork: Mainnet\n To claim this bounty sign up at https://openbounty.status.im and make sure to update your Ethereum address in My Payment Details so that the bounty is correctly allocated.\nTo fund it, send ETH or ERC20/ERC223 tokens to the contract address.'
const sobCommentWithWinner = 'Balance: 0.000000 ETH\nContract address: [0xe02fbffb3422ddb8e2227c3495f710ba4f8e0c10](https://etherscan.io/address/0xe02fbffb3422ddb8e2227c3495f710ba4f8e0c10)\nNetwork: Mainnet\nStatus: Pending maintainer confirmation\nWinner: foopang\nVisit [https://openbounty.status.im](https://openbounty.status.im) to learn more.' const sobCommentWithWinner = 'Balance: 0.000000 ETH\nContract address: [0xe02fbffb3422ddb8e2227c3495f710ba4f8e0c10](https://etherscan.io/address/0xe02fbffb3422ddb8e2227c3495f710ba4f8e0c10)\nNetwork: Mainnet\nStatus: Pending maintainer confirmation\nWinner: foopang\nVisit [https://openbounty.status.im](https://openbounty.status.im) to learn more.'
// Fake requests // Fake requests
@ -43,6 +43,9 @@ describe('Bot behavior', function () {
it('should return the address from a status-open-bounty bot comment', function () { it('should return the address from a status-open-bounty bot comment', function () {
assert.equal(bot.getAddress(requests[3]), '0x3645fe42b1a744ad98cc032c22472388806f86f9') assert.equal(bot.getAddress(requests[3]), '0x3645fe42b1a744ad98cc032c22472388806f86f9')
}) })
it('should not return the address from a comment not containing an address', function () {
assert.isUndefined(bot.getAddress(requests[1]))
})
}) })
describe('#getAmount', function () { describe('#getAmount', function () {