Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::statement("UPDATE transactions SET state = UPPER(state) WHERE state IN ('Abandoned', 'Pending', 'Processing', 'Broadcast', 'Executed', 'Finalized')");
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// No down migration needed, the uppercased state is the correct one.
}
};
6 changes: 3 additions & 3 deletions src/Commands/TransactionChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function handle(Substrate $client, Codec $codec): void

$maxBlockToCheck = $syncedBlocks?->last()?->number ?? 0;

$transactions = collect(Transaction::whereIn('state', [TransactionState::BROADCAST, TransactionState::EXECUTED])
$transactions = collect(Transaction::whereIn('state', [TransactionState::BROADCAST->name, TransactionState::EXECUTED->name])
->where('network', currentMatrix()->name)
->whereNotNull(['signed_at_block', 'transaction_chain_hash'])
// We only check transactions older than 100 blocks because ingest
Expand Down Expand Up @@ -166,10 +166,10 @@ public function handle(Substrate $client, Codec $codec): void
protected function setAbandonedState($hashes): void
{
Transaction::whereIn('transaction_chain_hash', $hashes)
->whereIn('state', [TransactionState::BROADCAST, TransactionState::EXECUTED])
->whereIn('state', [TransactionState::BROADCAST->name, TransactionState::EXECUTED->name])
->where('network', currentMatrix()->name)
->update([
'state' => TransactionState::ABANDONED,
'state' => TransactionState::ABANDONED->name,
]);

}
Expand Down
18 changes: 12 additions & 6 deletions tests/Feature/GraphQL/Mutations/AddToTrackedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AddToTrackedTest extends TestCaseGraphQL
protected function setUp(): void
{
parent::setUp();
\Illuminate\Support\Facades\RateLimiter::clear('AddToTrackedRequest:127.0.0.1');
}

// Data Providers
Expand All @@ -47,10 +48,13 @@ public static function validDataProvider(): array
fn () => Queue::assertPushed(HotSync::class),
],
'track multiple collections' => [
self::getInputData(chainIds: [
(string) fake()->unique()->numberBetween(2000),
(string) fake()->unique()->numberBetween(2000),
]),
self::getInputData(
chainIds: [
(string) fake()->unique()->numberBetween(2000),
(string) fake()->unique()->numberBetween(2000),
],
hotSync: false
),
fn () => Queue::assertPushed(HotSync::class),
],
'track multiple collections without hot sync' => [
Expand Down Expand Up @@ -87,10 +91,10 @@ public static function invalidDataProvider(): array
'too many chain ids supplied with hot sync' => [
[
'type' => ModelType::COLLECTION->name,
'chainIds' => array_map(fn () => (string) fake()->unique()->numberBetween(2000), array_fill(0, 11, null)),
'chainIds' => array_map(fn () => (string) fake()->unique()->numberBetween(2000), array_fill(0, 2, null)),
],
'chainIds',
'The chain ids field must not have more than 10 items.',
'The chain ids field must not have more than 1 items.',
],
'too many chain ids supplied without hot sync' => [
[
Expand Down Expand Up @@ -142,6 +146,8 @@ public function test_it_can_restore_tracked_data()
$deletedSyncable->delete();
$this->assertTrue($deletedSyncable->trashed());

\Illuminate\Support\Facades\RateLimiter::clear('AddToTrackedRequest:127.0.0.1');

$response = $this->graphql($this->method, $data);
$restoredSyncable = Syncable::withTrashed()->where('syncable_id', $data['chainIds'][0])->first();
$this->assertTrue($response);
Expand Down
Loading