Commit 9f3bcb40 authored by Ben Hayward's avatar Ben Hayward

fixed failing tests

1 merge request!251[Sprint/InterestingIguana](feat): Offchain boost rate limiting #475
Pipeline #72258346 passed with stages
in 8 minutes and 59 seconds
......@@ -298,10 +298,10 @@ class boost implements Interfaces\Api
}
if ($manager->boostLimitReached($boost)) {
$maxDaily = Di::_()->get('Config')->get('max_daily_boost_views');
$maxDaily = Di::_()->get('Config')->get('max_daily_boost_views') / 1000;
return Factory::response([
'status' => 'error',
'message' => "This boost would exceeded the maximum of ".$maxDaily." offchain tokens per day."
'message' => "Exceeded maximum of ".$maxDaily." offchain tokens per day."
]);
}
......
......@@ -13,6 +13,7 @@ use Minds\Entities\Activity;
use Minds\Entities\User;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Minds\Core\Di\Di;
class ManagerSpec extends ObjectBehavior
{
......@@ -321,12 +322,13 @@ class ManagerSpec extends ObjectBehavior
function it_should_recognise_a_user_has_reached_the_offchain_boost_limit(Boost $boost)
{
$boostArray = [];
for ($i = 1; $i < 11; $i++) {
for ($i = 0; $i < 10; $i++) {
$newBoost = new Boost();
$newBoost->setCreatedTimestamp('9999999999999999');
$newBoost->setImpressions(1000);
array_push($boostArray, $newBoost);
}
Di::_()->get('Config')->set('max_daily_boost_views', 10000);
$this->runThroughGetList($boost, $boostArray);
$this->boostLimitReached($boost)->shouldReturn(true);
}
......@@ -334,12 +336,13 @@ class ManagerSpec extends ObjectBehavior
function it_should_recognise_a_user_has_NOT_reached_the_offchain_boost_limit(Boost $boost)
{
$boostArray = [];
for ($i = 1; $i < 10; $i++) {
for ($i = 0; $i < 9; $i++) {
$newBoost = new Boost();
$newBoost->setCreatedTimestamp('9999999999999999');
$newBoost->setImpressions(1000);
array_push($boostArray, $newBoost);
}
Di::_()->get('Config')->set('max_daily_boost_views', 10000);
$this->runThroughGetList($boost, $boostArray);
$this->boostLimitReached($boost)->shouldReturn(false);
}
......@@ -348,14 +351,15 @@ class ManagerSpec extends ObjectBehavior
function it_should_recognise_a_boost_would_take_user_above_offchain_limit(Boost $boost)
{
$boostArray = [];
for ($i = 1; $i < 2; $i++) {
for ($i = 0; $i < 2; $i++) {
$newBoost = new Boost();
$newBoost->setCreatedTimestamp('9999999999999999');
$newBoost->setImpressions(4501);
array_push($boostArray, $newBoost);
}
Di::_()->get('Config')->set('max_daily_boost_views', 10000);
$this->runThroughGetList($boost, $boostArray);
$this->boostLimitReached($boost)->shouldReturn(false);
$this->boostLimitReached($boost)->shouldReturn(true);
}
function runThroughGetList($boost, $existingBoosts) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment