standardBountyInTokens.js
1 const StandardBounties = artifacts.require("../contracts/StandardBounties"); 2 const HumanStandardToken = artifacts.require("../contracts/inherited/HumanStandardToken"); 3 4 const utils = require('./helpers/Utils'); 5 6 7 contract('StandardBounties', function(accounts) { 8 9 it("[TOKENS] Verifies that the StandardBounties registry works", async () => { 10 11 let registry = await StandardBounties.new(accounts[0]); 12 13 let owner = await registry.owner(); 14 15 assert(owner == accounts[0]) 16 17 }); 18 19 it("[TOKENS] Verifies that I can issue a new bounty paying in Tokens", async () => { 20 let registry = await StandardBounties.new(accounts[0]); 21 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 22 23 await registry.issueBounty(0xF633f5bAf5954eE8F357055FE5151DDc27EEfdBF, 24 2528821098, 25 "data", 26 1000, 27 0x0, 28 true, 29 bountyToken.address,{from: accounts[0]}); 30 31 }); 32 33 it("[TOKENS] verifies that a date before the present will cause a failing construction", async () => { 34 let registry = await StandardBounties.new(accounts[0]); 35 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 36 37 try { 38 39 await registry.issueBounty(0xF633f5bAf5954eE8F357055FE5151DDc27EEfdBF, 40 0, 41 "data", 42 1000, 43 0x0, 44 true, 45 bountyToken.address,{from: accounts[0]}); 46 } catch (error){ 47 return utils.ensureException(error); 48 } 49 50 }); 51 52 it("[TOKENS] verifies that a payout of 0 will fail", async () => { 53 let registry = await StandardBounties.new(accounts[0]); 54 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 55 56 try { 57 58 await registry.issueBounty(0xF633f5bAf5954eE8F357055FE5151DDc27EEfdBF, 59 2528821098, 60 "data", 61 0, 62 0x0, 63 true, 64 bountyToken.address,{from: accounts[0]}); 65 } catch (error){ 66 return utils.ensureException(error); 67 } 68 69 }); 70 71 it("[TOKENS] verifies that simple bounty contribution and activation functions", async () => { 72 let registry = await StandardBounties.new(accounts[0]); 73 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 74 75 await registry.issueBounty(accounts[0], 76 2528821098, 77 "data", 78 1000, 79 0x0, 80 true, 81 bountyToken.address, 82 {from: accounts[0]}); 83 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 84 await registry.contribute(0,1000, {from: accounts[0]}); 85 let bounty = await registry.getBounty(0); 86 assert(bounty[4] == 0); 87 await registry.activateBounty(0,0, {from: accounts[0]}); 88 bounty = await registry.getBounty(0); 89 assert(bounty[4] == 1); 90 }); 91 it("[TOKENS] verifies that simple bounty activation functions", async () => { 92 let registry = await StandardBounties.new(accounts[0]); 93 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 94 95 await registry.issueBounty(accounts[0], 96 2528821098, 97 "data", 98 1000, 99 0x0, 100 true, 101 bountyToken.address, 102 {from: accounts[0]}); 103 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 104 await registry.activateBounty(0,1000, {from: accounts[0]}); 105 bounty = await registry.getBounty(0); 106 assert(bounty[4] == 1); 107 }); 108 it("[TOKENS] verifies that simple bounty activation functions for more than payout amount", async () => { 109 let registry = await StandardBounties.new(accounts[0]); 110 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 111 112 await registry.issueBounty(accounts[0], 113 2528821098, 114 "data", 115 1000, 116 0x0, 117 true, 118 bountyToken.address, 119 {from: accounts[0]}); 120 await bountyToken.approve(registry.address, 5000, {from: accounts[0]}); 121 await registry.activateBounty(0,5000, {from: accounts[0]}); 122 bounty = await registry.getBounty(0); 123 assert(bounty[4] == 1); 124 }); 125 it("[TOKENS] verifies that simple bounty activation with too small a value fails", async () => { 126 let registry = await StandardBounties.new(accounts[0]); 127 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 128 129 await registry.issueBounty(accounts[0], 130 2528821098, 131 "data", 132 1000, 133 0x0, 134 true, 135 bountyToken.address, 136 {from: accounts[0]}); 137 await bountyToken.approve(registry.address, 500, {from: accounts[0]}); 138 try { 139 await registry.activateBounty(0,500, {from: accounts[0]}); 140 141 } catch (error){ 142 return utils.ensureException(error); 143 } 144 }); 145 it("[TOKENS] verifies that simple bounty activation with wrong value fails", async () => { 146 let registry = await StandardBounties.new(accounts[0]); 147 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 148 149 await registry.issueBounty(accounts[0], 150 2528821098, 151 "data", 152 1000, 153 0x0, 154 true, 155 bountyToken.address, 156 {from: accounts[0]}); 157 await bountyToken.approve(registry.address, 500, {from: accounts[0]}); 158 try { 159 await registry.activateBounty(0,1000, {from: accounts[0]}); 160 161 } catch (error){ 162 return utils.ensureException(error); 163 } 164 }); 165 it("[TOKENS] verifies that bounty issuance and activation all in one functions", async () => { 166 let registry = await StandardBounties.new(accounts[0]); 167 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 168 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 169 await registry.issueAndActivateBounty(accounts[0], 170 2528821098, 171 "data", 172 1000, 173 0x0, 174 true, 175 bountyToken.address, 176 1000, 177 {from: accounts[0]}); 178 bounty = await registry.getBounty(0); 179 assert(bounty[4] == 1); 180 }); 181 it("[TOKENS] verifies that bounty issuance and activation all in one functions for more than payout amount", async () => { 182 let registry = await StandardBounties.new(accounts[0]); 183 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 184 await bountyToken.approve(registry.address, 5000, {from: accounts[0]}); 185 await registry.issueAndActivateBounty(accounts[0], 186 2528821098, 187 "data", 188 1000, 189 0x0, 190 true, 191 bountyToken.address, 192 5000, 193 {from: accounts[0],}); 194 bounty = await registry.getBounty(0); 195 assert(bounty[4] == 1); 196 }); 197 it("[TOKENS] verifies that bounty issuance and activation with incorrect value fails", async () => { 198 let registry = await StandardBounties.new(accounts[0]); 199 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 200 await bountyToken.approve(registry.address, 500, {from: accounts[0]}); 201 try { 202 await registry.issueAndActivateBounty(accounts[0], 203 2528821098, 204 "data", 205 1000, 206 0x0, 207 true, 208 bountyToken.address, 209 1000, 210 {from: accounts[0]}); 211 } catch (error){ 212 return utils.ensureException(error); 213 } 214 }); 215 it("[TOKENS] verifies that bounty issuance and activation with too small a value fails", async () => { 216 let registry = await StandardBounties.new(accounts[0]); 217 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 218 await bountyToken.approve(registry.address, 500, {from: accounts[0]}); 219 220 try { 221 await registry.issueAndActivateBounty(accounts[0], 222 2528821098, 223 "data", 224 1000, 225 0x0, 226 true, 227 bountyToken.address, 228 500, 229 {from: accounts[0]}); 230 } catch (error){ 231 return utils.ensureException(error); 232 } 233 }); 234 it("[TOKENS] verifies that bounty issuance and activation with date before today fails", async () => { 235 let registry = await StandardBounties.new(accounts[0]); 236 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 237 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 238 239 try { 240 await registry.issueAndActivateBounty(accounts[0], 241 0, 242 "data", 243 1000, 244 0x0, 245 true, 246 bountyToken.address, 247 1000, 248 {from: accounts[0]}); 249 } catch (error){ 250 return utils.ensureException(error); 251 } 252 }); 253 it("[TOKENS] verifies that bounty issuance and activation with payout of 0 fails", async () => { 254 let registry = await StandardBounties.new(accounts[0]); 255 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 256 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 257 258 try { 259 await registry.issueAndActivateBounty(accounts[0], 260 2528821098, 261 "data", 262 0, 263 0x0, 264 true, 265 bountyToken.address, 266 1000, 267 {from: accounts[0]}); 268 } catch (error){ 269 return utils.ensureException(error); 270 } 271 }); 272 it("[TOKENS] verifies that simple bounty contribution with incorrect value fails", async () => { 273 let registry = await StandardBounties.new(accounts[0]); 274 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 275 276 277 await registry.issueBounty(accounts[0], 278 2528821098, 279 "data", 280 1000, 281 0x0, 282 true, 283 bountyToken.address, 284 {from: accounts[0]}); 285 await bountyToken.approve(registry.address, 500, {from: accounts[0]}); 286 try { 287 await registry.contribute(0,1000, {from: accounts[0]}); 288 } catch (error){ 289 return utils.ensureException(error); 290 } 291 }); 292 293 it("[TOKENS] verifies that simple bounty contribution with a value of 0 fails", async () => { 294 let registry = await StandardBounties.new(accounts[0]); 295 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 296 297 await registry.issueBounty(accounts[0], 298 2528821098, 299 "data", 300 1000, 301 0x0, 302 true, 303 bountyToken.address, 304 {from: accounts[0]}); 305 await bountyToken.approve(registry.address, 0, {from: accounts[0]}); 306 try { 307 await registry.contribute(0,0, {from: accounts[0]}); 308 } catch (error){ 309 return utils.ensureException(error); 310 } 311 312 }); 313 it("[TOKENS] verifies that simple bounty contribution sending ETH to a token bounty fails", async () => { 314 let registry = await StandardBounties.new(accounts[0]); 315 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 316 317 await registry.issueBounty(accounts[0], 318 2528821098, 319 "data", 320 1000, 321 0x0, 322 true, 323 bountyToken.address, 324 {from: accounts[0]}); 325 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 326 try { 327 await registry.contribute(0,1000, {from: accounts[0], value: 1000}); 328 329 } catch (error){ 330 return utils.ensureException(error); 331 } 332 }); 333 it("[TOKENS] verifies that simple bounty activation sending ETH to a token bounty fails", async () => { 334 let registry = await StandardBounties.new(accounts[0]); 335 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 336 337 await registry.issueBounty(accounts[0], 338 2528821098, 339 "data", 340 1000, 341 0x0, 342 true, 343 bountyToken.address, 344 {from: accounts[0]}); 345 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 346 try { 347 await registry.activateBounty(0,1000, {from: accounts[0], value: 1000}); 348 349 } catch (error){ 350 return utils.ensureException(error); 351 } 352 }); 353 it("[TOKENS] verifies that activation before the bounty has sufficient funds fails", async () => { 354 let registry = await StandardBounties.new(accounts[0]); 355 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 356 357 await registry.issueBounty(accounts[0], 358 2528821098, 359 "data", 360 1000, 361 0x0, 362 true, 363 bountyToken.address, 364 {from: accounts[0]}); 365 await bountyToken.approve(registry.address, 500, {from: accounts[0]}); 366 await registry.contribute(0,500, {from: accounts[0]}); 367 try { 368 await registry.activateBounty(0,0, {from: accounts[0]}); 369 } catch (error){ 370 return utils.ensureException(error); 371 } 372 }); 373 it("[TOKENS] verifies that activation from non-issuer fails", async () => { 374 let registry = await StandardBounties.new(accounts[0]); 375 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 376 377 await registry.issueBounty(accounts[0], 378 2528821098, 379 "data", 380 1000, 381 0x0, 382 true, 383 bountyToken.address, 384 {from: accounts[0]}); 385 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 386 await registry.contribute(0,1000, {from: accounts[0]}); 387 try { 388 await registry.activateBounty(0,0, {from: accounts[1]}); 389 } catch (error){ 390 return utils.ensureException(error); 391 } 392 }); 393 it("[TOKENS] verifies that contribution fails for dead bounties", async () => { 394 let registry = await StandardBounties.new(accounts[0]); 395 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 396 397 await registry.issueBounty(accounts[0], 398 2528821098, 399 "data", 400 1000, 401 0x0, 402 true, 403 bountyToken.address, 404 {from: accounts[0]}); 405 await registry.killBounty(0); 406 await bountyToken.approve(registry.address, 500, {from: accounts[0]}); 407 try { 408 await registry.contribute(0,500, {from: accounts[0]}); 409 } catch (error){ 410 return utils.ensureException(error); 411 } 412 }); 413 it("[TOKENS] verifies that basic fulfillment acceptance flow works", async () => { 414 let registry = await StandardBounties.new(accounts[0]); 415 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 416 417 await registry.issueBounty(accounts[0], 418 2528821098, 419 "data", 420 1000, 421 0x0, 422 true, 423 bountyToken.address, 424 {from: accounts[0]}); 425 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 426 await registry.activateBounty(0,1000, {from: accounts[0]}); 427 428 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 429 let fulfillment = await registry.getFulfillment(0,0); 430 assert(fulfillment[0] === false); 431 await registry.acceptFulfillment(0,0,{from: accounts[0]}); 432 fulfillment = await registry.getFulfillment(0,0); 433 assert(fulfillment[0] === true); 434 }); 435 it("[TOKENS] verifies that changing a fulfillment works", async () => { 436 let registry = await StandardBounties.new(accounts[0]); 437 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 438 439 await registry.issueBounty(accounts[0], 440 2528821098, 441 "data", 442 1000, 443 0x0, 444 true, 445 bountyToken.address, 446 {from: accounts[0]}); 447 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 448 await registry.activateBounty(0,1000, {from: accounts[0]}); 449 450 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 451 let fulfillment = await registry.getFulfillment(0,0); 452 assert(fulfillment[2] === "data"); 453 await registry.updateFulfillment(0,0,"data2", {from: accounts[1]}); 454 fulfillment = await registry.getFulfillment(0,0); 455 assert(fulfillment[2] === "data2"); 456 }); 457 458 it("[TOKENS] verifies that changing an accepted fulfillment fails", async () => { 459 let registry = await StandardBounties.new(accounts[0]); 460 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 461 462 await registry.issueBounty(accounts[0], 463 2528821098, 464 "data", 465 1000, 466 0x0, 467 true, 468 bountyToken.address, 469 {from: accounts[0]}); 470 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 471 await registry.activateBounty(0,1000, {from: accounts[0]}); 472 473 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 474 let fulfillment = await registry.getFulfillment(0,0); 475 await registry.acceptFulfillment(0,0,{from: accounts[0]}); 476 477 try { 478 await registry.updateFulfillment(0,0,"data2", {from: accounts[1]}); 479 } catch (error){ 480 return utils.ensureException(error); 481 } 482 }); 483 484 it("[TOKENS] verifies that changing someone else's fulfillment fails", async () => { 485 let registry = await StandardBounties.new(accounts[0]); 486 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 487 488 await registry.issueBounty(accounts[0], 489 2528821098, 490 "data", 491 1000, 492 0x0, 493 true, 494 bountyToken.address, 495 {from: accounts[0]}); 496 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 497 await registry.activateBounty(0,1000, {from: accounts[0]}); 498 499 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 500 await registry.fulfillBounty(0, "data", {from: accounts[2]}); 501 502 try { 503 await registry.updateFulfillment(0,0,"data2", {from: accounts[2]}); 504 } catch (error){ 505 return utils.ensureException(error); 506 } 507 }); 508 it("[TOKENS] verifies that bounty fulfillment flow works to completion", async () => { 509 let registry = await StandardBounties.new(accounts[0]); 510 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 511 512 await registry.issueBounty(accounts[0], 513 2528821098, 514 "data", 515 1000, 516 0x0, 517 true, 518 bountyToken.address, 519 {from: accounts[0]}); 520 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 521 await registry.activateBounty(0,1000, {from: accounts[0]}); 522 523 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 524 let fulfillment = await registry.getFulfillment(0,0); 525 526 await registry.acceptFulfillment(0,0,{from: accounts[0]}); 527 fulfillment = await registry.getFulfillment(0,0); 528 var bounty = await registry.getBounty(0); 529 assert(bounty[5] == 0); 530 }); 531 it("[TOKENS] verifies that bounty fulfillment flow works to completion with several fulfillments", async () => { 532 let registry = await StandardBounties.new(accounts[0]); 533 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 534 535 await registry.issueBounty(accounts[0], 536 2528821098, 537 "data", 538 1000, 539 0x0, 540 true, 541 bountyToken.address, 542 {from: accounts[0]}); 543 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 544 await registry.activateBounty(0,1000, {from: accounts[0]}); 545 546 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 547 await registry.fulfillBounty(0, "data2", {from: accounts[2]}); 548 549 let fulfillment = await registry.getFulfillment(0,0); 550 551 await registry.acceptFulfillment(0,1,{from: accounts[0]}); 552 fulfillment = await registry.getFulfillment(0,0); 553 var bounty = await registry.getBounty(0); 554 assert(bounty[5] == 0); 555 }); 556 it("[TOKENS] verifies that arbiter can't fulfill a bounty", async () => { 557 let registry = await StandardBounties.new(accounts[0]); 558 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 559 560 await registry.issueBounty(accounts[0], 561 2528821098, 562 "data", 563 1000, 564 accounts[1], 565 true, 566 bountyToken.address, 567 {from: accounts[0]}); 568 await bountyToken.approve(registry.address, 2000, {from: accounts[0]}); 569 await registry.activateBounty(0,2000, {from: accounts[0]}); 570 try { 571 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 572 } catch (error){ 573 return utils.ensureException(error); 574 } 575 }); 576 it("[TOKENS] verifies that issuer can't fulfill a bounty", async () => { 577 let registry = await StandardBounties.new(accounts[0]); 578 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 579 580 await registry.issueBounty(accounts[0], 581 2528821098, 582 "data", 583 1000, 584 accounts[1], 585 true, 586 bountyToken.address, 587 {from: accounts[0]}); 588 await bountyToken.approve(registry.address, 2000, {from: accounts[0]}); 589 await registry.activateBounty(0,2000, {from: accounts[0]}); 590 try { 591 await registry.fulfillBounty(0, "data", {from: accounts[0]}); 592 } catch (error){ 593 return utils.ensureException(error); 594 } 595 }); 596 it("[TOKENS] verifies that accepting too many fulfillments isn't allowed", async () => { 597 let registry = await StandardBounties.new(accounts[0]); 598 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 599 600 await registry.issueBounty(accounts[0], 601 2528821098, 602 "data", 603 1000, 604 0x0, 605 true, 606 bountyToken.address, 607 {from: accounts[0]}); 608 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 609 await registry.activateBounty(0,1000, {from: accounts[0]}); 610 611 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 612 await registry.fulfillBounty(0, "data2", {from: accounts[2]}); 613 await registry.fulfillBounty(0, "data3", {from: accounts[3]}); 614 let bounty = await registry.getBounty(0); 615 let balance = await bountyToken.balanceOf(registry.address); 616 assert(bounty[5]== 1000); 617 assert(balance == 1000); 618 await registry.acceptFulfillment(0,2,{from: accounts[0]}); 619 bounty = await registry.getBounty(0); 620 balance = await bountyToken.balanceOf(registry.address); 621 assert(bounty[5]== 0); 622 assert(balance == 0); 623 try { 624 await registry.acceptFulfillment(0,2,{from: accounts[0]}); 625 } catch (error){ 626 return utils.ensureException(error); 627 } 628 }); 629 it("[TOKENS] verifies that accepting an already accepted fulfillment fails", async () => { 630 let registry = await StandardBounties.new(accounts[0]); 631 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 632 633 await registry.issueBounty(accounts[0], 634 2528821098, 635 "data", 636 1000, 637 0x0, 638 true, 639 bountyToken.address, 640 {from: accounts[0]}); 641 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 642 await registry.activateBounty(0,1000, {from: accounts[0]}); 643 644 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 645 await registry.fulfillBounty(0, "data", {from: accounts[2]}); 646 647 await registry.acceptFulfillment(0,0,{from: accounts[0]}); 648 649 let fulfillment = await registry.getFulfillment(0,0); 650 assert(fulfillment[0] == true); 651 652 try { 653 await registry.acceptFulfillment(0,0,{from: accounts[0]}); 654 655 } catch (error){ 656 return utils.ensureException(error); 657 } 658 }); 659 it("[TOKENS] verifies that issuer can transfer ownership of a draft bounty to a new account", async () => { 660 let registry = await StandardBounties.new(accounts[0]); 661 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 662 663 await registry.issueBounty(accounts[0], 664 2528821098, 665 "data", 666 1000, 667 0x0, 668 true, 669 bountyToken.address, 670 {from: accounts[0]}); 671 await registry.transferIssuer(0, accounts[1], {from: accounts[0]}); 672 let bounty = await registry.getBounty(0); 673 assert(bounty[0] == accounts[1]); 674 675 }); 676 it("[TOKENS] verifies that issuer can transfer ownership of an active bounty to a new account", async () => { 677 let registry = await StandardBounties.new(accounts[0]); 678 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 679 680 await registry.issueBounty(accounts[0], 681 2528821098, 682 "data", 683 1000, 684 0x0, 685 true, 686 bountyToken.address, 687 {from: accounts[0]}); 688 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 689 await registry.activateBounty(0, 1000, {from: accounts[0]}); 690 await registry.transferIssuer(0, accounts[1], {from: accounts[0]}); 691 let bounty = await registry.getBounty(0); 692 assert(bounty[0] == accounts[1]); 693 }); 694 it("[TOKENS] verifies that issuer can extend the deadline of an active bounty", async () => { 695 let registry = await StandardBounties.new(accounts[0]); 696 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 697 698 await registry.issueBounty(accounts[0], 699 2528821098, 700 "data", 701 1000, 702 0x0, 703 true, 704 bountyToken.address, 705 {from: accounts[0]}); 706 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 707 await registry.activateBounty(0, 1000, {from: accounts[0]}); 708 await registry.extendDeadline(0, 2528821099, {from: accounts[0]}); 709 let bounty = await registry.getBounty(0); 710 assert(bounty[1] == 2528821099); 711 }); 712 713 it("[TOKENS] verifies that issuer can extend the deadline of an active bounty into an earlier date", async () => { 714 let registry = await StandardBounties.new(accounts[0]); 715 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 716 717 await registry.issueBounty(accounts[0], 718 2528821098, 719 "data", 720 1000, 721 0x0, 722 true, 723 bountyToken.address, 724 {from: accounts[0]}); 725 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 726 await registry.activateBounty(0, 1000, {from: accounts[0]}); 727 try { 728 await registry.extendDeadline(0, 2528821097, {from: accounts[0]}); 729 } catch(error){ 730 return utils.ensureException(error); 731 } 732 }); 733 734 it("[TOKENS] verifies that issuer can extend the deadline of an active bounty into a much earlier date", async () => { 735 let registry = await StandardBounties.new(accounts[0]); 736 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 737 738 await registry.issueBounty(accounts[0], 739 2528821098, 740 "data", 741 1000, 742 0x0, 743 true, 744 bountyToken.address, 745 {from: accounts[0]}); 746 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 747 await registry.activateBounty(0, 1000, {from: accounts[0]}); 748 try { 749 await registry.extendDeadline(0, 2028821097, {from: accounts[0]}); 750 } catch(error){ 751 return utils.ensureException(error); 752 } 753 }); 754 it("[TOKENS] verifies that I can change the deadline of a draft bounty", async () => { 755 let registry = await StandardBounties.new(accounts[0]); 756 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 757 758 await registry.issueBounty(accounts[0], 759 2528821098, 760 "data", 761 1000, 762 0x0, 763 true, 764 bountyToken.address, 765 {from: accounts[0]}); 766 await registry.changeBountyDeadline(0, 2028821098, {from: accounts[0]}); 767 768 let bounty = await registry.getBounty(0); 769 assert(bounty[1] == 2028821098); 770 771 }); 772 it("[TOKENS] verifies that I can change the data of a draft bounty", async () => { 773 let registry = await StandardBounties.new(accounts[0]); 774 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 775 776 await registry.issueBounty(accounts[0], 777 2528821098, 778 "data", 779 1000, 780 0x0, 781 true, 782 bountyToken.address, 783 {from: accounts[0]}); 784 await registry.changeBountyData(0, "newData", {from: accounts[0]}); 785 786 let bounty = await registry.getBountyData(0); 787 assert(bounty == "newData"); 788 789 }); 790 it("[TOKENS] verifies that I can decrease the fulfillment amount of a draft bounty", async () => { 791 let registry = await StandardBounties.new(accounts[0]); 792 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 793 794 await registry.issueBounty(accounts[0], 795 2528821098, 796 "data", 797 1000, 798 0x0, 799 true, 800 bountyToken.address, 801 {from: accounts[0]}); 802 await registry.changeBountyFulfillmentAmount(0, 500, {from: accounts[0]}); 803 804 let bounty = await registry.getBounty(0); 805 assert(bounty[2] == 500); 806 }); 807 it("[TOKENS] verifies that I can increase the fulfillment amount of a draft bounty", async () => { 808 let registry = await StandardBounties.new(accounts[0]); 809 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 810 811 await registry.issueBounty(accounts[0], 812 2528821098, 813 "data", 814 1000, 815 0x0, 816 true, 817 bountyToken.address, 818 {from: accounts[0]}); 819 await registry.changeBountyFulfillmentAmount(0, 2000, {from: accounts[0]}); 820 821 let bounty = await registry.getBounty(0); 822 assert(bounty[2] == 2000); 823 }); 824 825 it("[TOKENS] verifies that I can change the arbiter of a draft bounty", async () => { 826 let registry = await StandardBounties.new(accounts[0]); 827 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 828 829 await registry.issueBounty(accounts[0], 830 2528821098, 831 "data", 832 1000, 833 accounts[1], 834 true, 835 bountyToken.address, 836 {from: accounts[0]}); 837 let arbiter = await registry.getBountyArbiter(0); 838 assert(arbiter == accounts[1]); 839 await registry.changeBountyArbiter(0, accounts[2], {from: accounts[0]}); 840 841 arbiter = await registry.getBountyArbiter(0); 842 assert(arbiter == accounts[2]); 843 844 }); 845 it("[TOKENS] verifies that I can't change the deadline of an active bounty", async () => { 846 let registry = await StandardBounties.new(accounts[0]); 847 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 848 849 await registry.issueBounty(accounts[0], 850 2528821098, 851 "data", 852 1000, 853 0x0, 854 true, 855 bountyToken.address, 856 {from: accounts[0]}); 857 858 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 859 await registry.activateBounty(0, 1000, {from: accounts[0]}); 860 try { 861 await registry.changeBountyDeadline(0, 2028821098, {from: accounts[0]}); 862 } catch(error){ 863 return utils.ensureException(error); 864 } 865 866 }); 867 it("[TOKENS] verifies that I can't change the data of an active bounty", async () => { 868 let registry = await StandardBounties.new(accounts[0]); 869 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 870 871 await registry.issueBounty(accounts[0], 872 2528821098, 873 "data", 874 1000, 875 0x0, 876 true, 877 bountyToken.address, 878 {from: accounts[0]}); 879 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 880 await registry.activateBounty(0, 1000, {from: accounts[0]}); 881 try { 882 await registry.changeBountyData(0, "newData", {from: accounts[0]}); 883 } catch(error){ 884 return utils.ensureException(error); 885 } 886 887 }); 888 it("[TOKENS] verifies that I can't decrease the fulfillment amount of an active bounty", async () => { 889 let registry = await StandardBounties.new(accounts[0]); 890 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 891 892 await registry.issueBounty(accounts[0], 893 2528821098, 894 "data", 895 1000, 896 0x0, 897 true, 898 bountyToken.address, 899 {from: accounts[0]}); 900 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 901 await registry.activateBounty(0, 1000, {from: accounts[0]}); 902 try { 903 await registry.changeBountyFulfillmentAmount(0, 500, {from: accounts[0]}); 904 } catch(error){ 905 return utils.ensureException(error); 906 } 907 }); 908 it("[TOKENS] verifies that I can't increase the fulfillment amount of an active bounty", async () => { 909 let registry = await StandardBounties.new(accounts[0]); 910 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 911 912 await registry.issueBounty(accounts[0], 913 2528821098, 914 "data", 915 1000, 916 0x0, 917 true, 918 bountyToken.address, 919 {from: accounts[0]}); 920 921 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 922 await registry.activateBounty(0, 1000, {from: accounts[0]}); 923 try { 924 await registry.changeBountyFulfillmentAmount(0, 2000, {from: accounts[0]}); 925 } catch(error){ 926 return utils.ensureException(error); 927 } 928 }); 929 930 it("[TOKENS] verifies that I can't change the arbiter of an active bounty", async () => { 931 let registry = await StandardBounties.new(accounts[0]); 932 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 933 934 await registry.issueBounty(accounts[0], 935 2528821098, 936 "data", 937 1000, 938 accounts[1], 939 true, 940 bountyToken.address, 941 {from: accounts[0]}); 942 943 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 944 await registry.activateBounty(0, 1000, {from: accounts[0]}); 945 try { 946 await registry.changeBountyArbiter(0, accounts[2], {from: accounts[0]}); 947 } catch(error){ 948 return utils.ensureException(error); 949 } 950 951 }); 952 953 it("[TOKENS] verifies that issuer must redeposit funds after killing a bounty", async () => { 954 let registry = await StandardBounties.new(accounts[0]); 955 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 956 957 await registry.issueBounty(accounts[0], 958 2528821098, 959 "data", 960 1000, 961 0x0, 962 true, 963 bountyToken.address, 964 {from: accounts[0]}); 965 await bountyToken.approve(registry.address, 2000, {from: accounts[0]}); 966 await registry.activateBounty(0,2000, {from: accounts[0]}); 967 968 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 969 970 await registry.acceptFulfillment(0,0,{from: accounts[0]}); 971 972 let bounty = await registry.getBounty(0); 973 assert(bounty[5] == 1000); 974 975 await registry.killBounty(0,{from: accounts[0]}); 976 977 bounty = await registry.getBounty(0); 978 assert(bounty[5] == 0); 979 980 try { 981 await registry.activateBounty(0, 0, {from: accounts[0]}); 982 983 } catch (error){ 984 return utils.ensureException(error); 985 } 986 }); 987 988 it("[TOKENS] verifies that issuer must redeposit sufficient funds to pay a fulfillment after killing a bounty", async () => { 989 let registry = await StandardBounties.new(accounts[0]); 990 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 991 992 await registry.issueBounty(accounts[0], 993 2528821098, 994 "data", 995 1000, 996 0x0, 997 true, 998 bountyToken.address, 999 {from: accounts[0]}); 1000 await bountyToken.approve(registry.address, 2000, {from: accounts[0]}); 1001 await registry.activateBounty(0,2000, {from: accounts[0]}); 1002 1003 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 1004 1005 await registry.acceptFulfillment(0,0,{from: accounts[0]}); 1006 1007 let bounty = await registry.getBounty(0); 1008 assert(bounty[5] == 1000); 1009 1010 await registry.killBounty(0,{from: accounts[0]}); 1011 1012 bounty = await registry.getBounty(0); 1013 assert(bounty[5] == 0); 1014 1015 await bountyToken.approve(registry.address, 500, {from: accounts[0]}); 1016 try { 1017 await registry.activateBounty(0, 500, {from: accounts[0]}); 1018 1019 } catch (error){ 1020 return utils.ensureException(error); 1021 } 1022 }); 1023 it("[TOKENS] verifies that reactivating a bounty works when the sufficient amount is deposited", async () => { 1024 let registry = await StandardBounties.new(accounts[0]); 1025 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 1026 1027 await registry.issueBounty(accounts[0], 1028 2528821098, 1029 "data", 1030 1000, 1031 0x0, 1032 true, 1033 bountyToken.address, 1034 {from: accounts[0]}); 1035 await bountyToken.approve(registry.address, 2000, {from: accounts[0]}); 1036 await registry.activateBounty(0,2000, {from: accounts[0]}); 1037 1038 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 1039 1040 await registry.acceptFulfillment(0,0,{from: accounts[0]}); 1041 1042 let bounty = await registry.getBounty(0); 1043 assert(bounty[5] == 1000); 1044 1045 await registry.killBounty(0,{from: accounts[0]}); 1046 1047 bounty = await registry.getBounty(0); 1048 assert(bounty[4] == 2); 1049 1050 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 1051 await registry.activateBounty(0, 1000, {from: accounts[0]}); 1052 1053 bounty = await registry.getBounty(0); 1054 assert(bounty[4] == 1); 1055 1056 }); 1057 1058 it("[TOKENS] verifies that increasing a payout amount for an unaccepted fulfillment works", async () => { 1059 let registry = await StandardBounties.new(accounts[0]); 1060 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 1061 1062 await registry.issueBounty(accounts[0], 1063 2528821098, 1064 "data", 1065 1000, 1066 0x0, 1067 true, 1068 bountyToken.address, 1069 {from: accounts[0]}); 1070 await bountyToken.approve(registry.address, 2000, {from: accounts[0]}); 1071 await registry.activateBounty(0,2000, {from: accounts[0]}); 1072 1073 let bounty = await registry.getBounty(0); 1074 assert(bounty[2] == 1000); 1075 assert(bounty[5] == 2000); 1076 1077 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 1078 1079 bounty = await registry.getBounty(0); 1080 assert(bounty[2] == 1000); 1081 assert(bounty[5] == 2000); 1082 1083 await registry.increasePayout(0,2000, 0, {from: accounts[0]}); 1084 1085 bounty = await registry.getBounty(0); 1086 assert(bounty[2] == 2000); 1087 assert(bounty[5] == 2000); 1088 1089 await registry.acceptFulfillment(0,0, {from: accounts[0]}); 1090 bounty = await registry.getBounty(0); 1091 assert(bounty[5] == 0); 1092 1093 1094 }); 1095 it("[TOKENS] verifies that increasing a payout amount with value works", async () => { 1096 let registry = await StandardBounties.new(accounts[0]); 1097 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 1098 1099 await registry.issueBounty(accounts[0], 1100 2528821098, 1101 "data", 1102 1000, 1103 0x0, 1104 true, 1105 bountyToken.address, 1106 {from: accounts[0]}); 1107 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 1108 await registry.activateBounty(0,1000, {from: accounts[0]}); 1109 1110 let bounty = await registry.getBounty(0); 1111 assert(bounty[2] == 1000); 1112 assert(bounty[5] == 1000); 1113 1114 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 1115 1116 bounty = await registry.getBounty(0); 1117 assert(bounty[2] == 1000); 1118 assert(bounty[5] == 1000); 1119 1120 await bountyToken.approve(registry.address, 1000, {from: accounts[0]}); 1121 await registry.increasePayout(0,2000, 1000, {from: accounts[0]}); 1122 1123 bounty = await registry.getBounty(0); 1124 assert(bounty[2] == 2000); 1125 assert(bounty[5] == 2000); 1126 1127 await registry.acceptFulfillment(0,0, {from: accounts[0]}); 1128 bounty = await registry.getBounty(0); 1129 assert(bounty[5] == 0); 1130 }); 1131 it("[TOKENS] verifies that increasing a payout amount for an accepted fulfillment works", async () => { 1132 let registry = await StandardBounties.new(accounts[0]); 1133 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 1134 1135 await registry.issueBounty(accounts[0], 1136 2528821098, 1137 "data", 1138 1000, 1139 0x0, 1140 true, 1141 bountyToken.address, 1142 {from: accounts[0]}); 1143 await bountyToken.approve(registry.address, 3000, {from: accounts[0]}); 1144 await registry.activateBounty(0,3000, {from: accounts[0]}); 1145 1146 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 1147 let bounty = await registry.getBounty(0); 1148 assert(bounty[2] == 1000); 1149 assert(bounty[5] == 3000); 1150 1151 await registry.acceptFulfillment(0,0, {from: accounts[0]}); 1152 1153 bounty = await registry.getBounty(0); 1154 assert(bounty[2] == 1000); 1155 assert(bounty[5] == 2000); 1156 1157 await registry.increasePayout(0, 2000, 0, {from: accounts[0]}); 1158 1159 bounty = await registry.getBounty(0); 1160 assert(bounty[2] == 2000); 1161 assert(bounty[5] == 2000); 1162 1163 }); 1164 1165 it("[TOKENS] verifies that increasing a payout amount with too small of a balance fails", async () => { 1166 let registry = await StandardBounties.new(accounts[0]); 1167 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 1168 1169 await registry.issueBounty(accounts[0], 1170 2528821098, 1171 "data", 1172 1000, 1173 0x0, 1174 true, 1175 bountyToken.address, 1176 {from: accounts[0]}); 1177 await bountyToken.approve(registry.address, 3000, {from: accounts[0]}); 1178 await registry.activateBounty(0,3000, {from: accounts[0]}); 1179 1180 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 1181 await registry.fulfillBounty(0, "data2", {from: accounts[2]}); 1182 1183 await registry.acceptFulfillment(0,0, {from: accounts[0]}); 1184 await registry.acceptFulfillment(0,1, {from: accounts[0]}); 1185 1186 try { 1187 await registry.increasePayout(0,2000, 0, {from: accounts[0]}); 1188 } catch(error){ 1189 return utils.ensureException(error); 1190 } 1191 1192 1193 1194 }); 1195 it("[TOKENS] verifies that increasing the payout with a lower amount fails", async () => { 1196 let registry = await StandardBounties.new(accounts[0]); 1197 let bountyToken = await HumanStandardToken.new(1000000000, "Bounty Token", 18, "BOUNT"); 1198 1199 await registry.issueBounty(accounts[0], 1200 2528821098, 1201 "data", 1202 1000, 1203 0x0, 1204 true, 1205 bountyToken.address, 1206 {from: accounts[0]}); 1207 await bountyToken.approve(registry.address, 3000, {from: accounts[0]}); 1208 await registry.activateBounty(0,3000, {from: accounts[0]}); 1209 1210 await registry.fulfillBounty(0, "data", {from: accounts[1]}); 1211 await registry.fulfillBounty(0, "data2", {from: accounts[2]}); 1212 1213 try { 1214 await registry.increasePayout(0,900, 0, {from: accounts[0]}); 1215 } catch(error){ 1216 return utils.ensureException(error); 1217 } 1218 1219 }); 1220 1221 1222 1223 1224 1225 });