diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index fb0ba12b9..c7030f3ab 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -14,8 +14,8 @@ concurrency: cancel-in-progress: true jobs: - test-unit: - name: test-unit + test-unit-short: + name: test-unit-short strategy: fail-fast: false matrix: @@ -38,6 +38,30 @@ jobs: - name: Test run: make test-unit + test-unit-all: + name: test-unit-all + strategy: + fail-fast: false + matrix: + go-version: [1.25.7] + goarch: ["amd64"] + runs-on: amd-runner-2204 + steps: + - name: Checkout code + uses: actions/checkout@v5 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Install Go + uses: actions/setup-go@v6 + with: + go-version: ${{ matrix.go-version }} + env: + GOARCH: ${{ matrix.goarch }} + + - name: Test + run: make test-unit-all + - name: SonarQube Scan uses: SonarSource/sonarqube-scan-action@v6.0.0 env: diff --git a/Makefile b/Makefile index b6e0a796b..12ea58fd1 100644 --- a/Makefile +++ b/Makefile @@ -102,9 +102,13 @@ build-docker-debug: ## Builds a debug docker image (dlv headless on :40000, no o docker build -t aggkit:local-debug -f ./Dockerfile.debug . .PHONY: test-unit -test-unit: ## Runs the unit tests +test-unit: ## Runs the short unit tests trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -short -race -p 1 -covermode=atomic -coverprofile=coverage.out -timeout 15m ./... +.PHONY: test-unit-all +test-unit-all: ## Runs all unit tests + trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -race -p 1 -covermode=atomic -coverprofile=coverage.out -timeout 15m ./... + .PHONY: test-e2e test-e2e: ## Runs the e2e tests go test -v -timeout 30m ./test/e2e/... diff --git a/aggoracle/e2e_test.go b/aggoracle/e2e_test.go index d20b2e808..4c4fea0cf 100644 --- a/aggoracle/e2e_test.go +++ b/aggoracle/e2e_test.go @@ -13,6 +13,9 @@ import ( ) func TestEVM_GERInjection(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } tests := []struct { name string enableAggOracleCommittee bool @@ -72,6 +75,9 @@ func TestEVM_GERInjection(t *testing.T) { } func TestEVM_AggOracleCommitteeModeWithQuorum3(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } cfg := helpers.DefaultEnvironmentConfig(helpers.SovereignChainL2GERContract) cfg.AggOracleCommitteeCfg.EnableAggOracleCommittee = true cfg.AggOracleCommitteeCfg.Quorum = 3 diff --git a/bridgesync/backfill_tx_sender_test.go b/bridgesync/backfill_tx_sender_test.go index 3b6429219..687e2ad5c 100644 --- a/bridgesync/backfill_tx_sender_test.go +++ b/bridgesync/backfill_tx_sender_test.go @@ -1840,6 +1840,9 @@ func TestBackfillTxnSender_getRecordsNeedingBackfill_Cases(t *testing.T) { } func TestBackfillTxnSenderIntegration(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } // Skip integration test if no RPC URL is provided rpcURL := os.Getenv("TEST_RPC_URL") if rpcURL == "" { diff --git a/bridgesync/e2e_test.go b/bridgesync/e2e_test.go index 6d25b3857..b886bbc27 100644 --- a/bridgesync/e2e_test.go +++ b/bridgesync/e2e_test.go @@ -56,6 +56,9 @@ func mockClientCallGetTransactionByHash(t *testing.T, } func TestBridgeEventE2E(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } const ( blockTime = time.Millisecond * 10 totalBridges = 80 @@ -178,6 +181,9 @@ func getFinalizedBlockNumber(t *testing.T, ctx context.Context, client simulated // TestBridgeL1SyncerWithReorgDetector tests the bridge L1 syncer with reorg detector func TestBridgeL1SyncerWithReorgDetector(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx := context.Background() dbPathSyncer := path.Join(t.TempDir(), "bridgesyncTestWithReorgs_sync.sqlite") dbPathReorg := path.Join(t.TempDir(), "bridgesyncTestWithReorgs_reorg.sqlite") @@ -363,6 +369,9 @@ func TestBridgeL1SyncerWithReorgDetector(t *testing.T) { // TestReorgWithSameHashEdgeCase tests reorg detection when blocks have same hash func TestReorgWithSameHashEdgeCase(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx := context.Background() dbPathSyncer := path.Join(t.TempDir(), "bridgesyncTestSameHashReorg_sync.sqlite") dbPathReorg := path.Join(t.TempDir(), "bridgesyncTestSameHashReorg_reorg.sqlite") @@ -482,6 +491,9 @@ func TestReorgWithSameHashEdgeCase(t *testing.T) { // TestBridgeL1SyncerWithMultipleReorgs tests the bridge L1 syncer with multiple reorgs func TestBridgeL1SyncerWithMultipleReorgs(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx := context.Background() dbPathSyncer := path.Join(t.TempDir(), "bridgesyncTestWithReorgs_sync.sqlite") dbPathReorg := path.Join(t.TempDir(), "bridgesyncTestWithReorgs_reorg.sqlite") diff --git a/claimsync/agglayer_bridge_l2_reader_test.go b/claimsync/agglayer_bridge_l2_reader_test.go index 22465bf2a..faa0404ed 100644 --- a/claimsync/agglayer_bridge_l2_reader_test.go +++ b/claimsync/agglayer_bridge_l2_reader_test.go @@ -257,6 +257,9 @@ func TestAgglayerBridgeL2Reader_GetUnsetClaimsForBlockRange_IteratorCloseError(t // Test with simulated backend to get real contract behavior func TestAgglayerBridgeL2Reader_GetUnsetClaimsForBlockRange_SimulatedBackend(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx := context.Background() bridgeAddr := common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678") @@ -282,6 +285,9 @@ func TestAgglayerBridgeL2Reader_GetUnsetClaimsForBlockRange_SimulatedBackend(t * // Test with real contract events to test iterator behavior func TestAgglayerBridgeL2Reader_GetUnsetClaimsForBlockRange_WithRealEvents(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx := context.Background() bridgeAddr := common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678") @@ -310,6 +316,9 @@ func TestAgglayerBridgeL2Reader_GetUnsetClaimsForBlockRange_WithRealEvents(t *te // Test the actual iterator behavior by creating a test that exercises the iterator loop func TestAgglayerBridgeL2Reader_GetUnsetClaimsForBlockRange_IteratorBehavior(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx := context.Background() bridgeAddr := common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678") diff --git a/claimsync/claimcalldata_test.go b/claimsync/claimcalldata_test.go index a7f502093..ae3f240fc 100644 --- a/claimsync/claimcalldata_test.go +++ b/claimsync/claimcalldata_test.go @@ -26,6 +26,9 @@ type testCase struct { } func TestClaimCalldata(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } testCases := make([]testCase, 0, 46) ctx, cancelFn := context.WithCancel(context.Background()) diff --git a/claimsync/claimsync_test.go b/claimsync/claimsync_test.go index b372800bf..9c7833e07 100644 --- a/claimsync/claimsync_test.go +++ b/claimsync/claimsync_test.go @@ -60,6 +60,9 @@ func TestGetLastBlockNumByGlobalIndexFromRPC_Exploratory(t *testing.T) { // 5. Call SetNextRequiredBlock(ctx, 1) to unlock the syncer. // 6. Assert GetLastProcessedBlock returns found=true — the syncer processed the blocks and captured the event. func TestClaimSyncerWaitUntilSetNextRequiredBlock(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx, cancelFn := context.WithCancel(context.Background()) // Setup Docker L1 client, auth := startGeth(t, ctx, cancelFn) diff --git a/etherman/querier/rollup_data_querier_test.go b/etherman/querier/rollup_data_querier_test.go index 8972f10f9..92c33e235 100644 --- a/etherman/querier/rollup_data_querier_test.go +++ b/etherman/querier/rollup_data_querier_test.go @@ -238,6 +238,9 @@ func TestFetchRollupID(t *testing.T) { } func TestRollupDataQuerier_GetUpgradeBlock(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } const ( latestAgglayerManagerVersion = uint8(5) startBlock = uint64(0) diff --git a/l1infotreesync/e2e_test.go b/l1infotreesync/e2e_test.go index f706b8905..deac55bae 100644 --- a/l1infotreesync/e2e_test.go +++ b/l1infotreesync/e2e_test.go @@ -70,6 +70,9 @@ func newSimulatedClient(t *testing.T) ( } func TestE2E(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx := t.Context() dbPath := path.Join(t.TempDir(), "l1infotreesyncTestE2E.sqlite") @@ -164,6 +167,9 @@ func TestE2E(t *testing.T) { func TestWithReorgs(t *testing.T) { t.Parallel() + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } tests := []struct { name string useMultidownloaderForTest bool @@ -399,6 +405,9 @@ func showLeafs(t *testing.T, ctx context.Context, syncer *l1infotreesync.L1InfoT } func TestStressAndReorgs(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } t.Skip("Skipping E2E test, this test is works locally but fails in CI") const ( totalIterations = 3 diff --git a/l2gersync/e2e_test.go b/l2gersync/e2e_test.go index 301f0dccc..c5b49323c 100644 --- a/l2gersync/e2e_test.go +++ b/l2gersync/e2e_test.go @@ -29,6 +29,9 @@ const ( ) func TestL2GERSyncE2E(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } t.Parallel() t.Skip("Skipping E2E test, this test is broken and needs a PR to be fixed. The lastProcessedBlock doesn't take in account empty blocks") @@ -65,6 +68,9 @@ func TestL2GERSyncE2E(t *testing.T) { } func TestL2GERSync_GERRemoval(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } t.Parallel() t.Skip("Skipping E2E test, this test is broken and needs a PR to be fixed. The lastProcessedBlock doesn't take in account empty blocks") @@ -130,6 +136,9 @@ func TestL2GERSync_GERRemoval(t *testing.T) { } func TestL2GERSync_IndexLegacyGERManagerSC(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } t.Parallel() ctx := context.Background() diff --git a/l2gersync/l2_evm_ger_reader_test.go b/l2gersync/l2_evm_ger_reader_test.go index 45764085d..d6a9b12f7 100644 --- a/l2gersync/l2_evm_ger_reader_test.go +++ b/l2gersync/l2_evm_ger_reader_test.go @@ -49,6 +49,9 @@ func TestValidateL2GERContract(t *testing.T) { func TestL2EVMGERReader_GetInjectedGERsForRange(t *testing.T) { t.Parallel() + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx := context.Background() @@ -170,6 +173,9 @@ func TestL2EVMGERReader_GetInjectedGERsForRange(t *testing.T) { func TestL2EVMGERReader_GetRemovedGERsForRange(t *testing.T) { t.Parallel() + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx := context.Background() diff --git a/pprof/pprof_test.go b/pprof/pprof_test.go index 5a4c59201..5feea3b21 100644 --- a/pprof/pprof_test.go +++ b/pprof/pprof_test.go @@ -13,6 +13,9 @@ import ( ) func TestStartProfilingHttpServer(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } // Mock configuration config := Config{ ProfilingHost: "127.0.0.1", diff --git a/reorgdetector/reorgdetector_test.go b/reorgdetector/reorgdetector_test.go index 2808a3cce..d3d6f1536 100644 --- a/reorgdetector/reorgdetector_test.go +++ b/reorgdetector/reorgdetector_test.go @@ -107,6 +107,9 @@ func Test_ReorgDetector(t *testing.T) { } func TestGetTrackedBlocks(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } clientL1 := simulated.NewBackend(nil, simulated.WithBlockGasLimit(10000000)) testDir := path.Join(t.TempDir(), "reorgdetector_TestGetTrackedBlocks.sqlite") reorgDetector, err := New(etherman.NewDefaultEthClient(clientL1.Client(), nil, nil), Config{ @@ -208,6 +211,9 @@ func TestGetTrackedBlocks(t *testing.T) { } func TestNotSubscribed(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } clientL1 := simulated.NewBackend(nil, simulated.WithBlockGasLimit(10000000)) testDir := path.Join(t.TempDir(), "reorgdetectorTestNotSubscribed.sqlite") reorgDetector, err := New(etherman.NewDefaultEthClient(clientL1.Client(), nil, nil), @@ -219,6 +225,9 @@ func TestNotSubscribed(t *testing.T) { func TestDetectReorgs(t *testing.T) { t.Parallel() + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx := context.Background() syncerID := "test-syncer" @@ -314,6 +323,9 @@ func TestDetectReorgs(t *testing.T) { } func TestLoadTrackedHeaders_ConcurrentWithSaveTrackedBlock(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } clientL1 := simulated.NewBackend(nil, simulated.WithBlockGasLimit(10000000)) testDir := path.Join(t.TempDir(), "reorgdetectorTestConcurrentSave.sqlite") reorgDetector, err := New(etherman.NewDefaultEthClient(clientL1.Client(), nil, nil), Config{ @@ -363,6 +375,9 @@ func TestLoadTrackedHeaders_ConcurrentWithSaveTrackedBlock(t *testing.T) { } func TestGetTrackedBlockByBlockNumber(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } ctx := context.Background() clientL1 := simulated.NewBackend(nil, simulated.WithBlockGasLimit(10000000)) testDir := path.Join(t.TempDir(), "reorgdetectorTestGetTrackedBlockByBlockNumber.sqlite") @@ -402,6 +417,9 @@ func TestGetTrackedBlockByBlockNumber(t *testing.T) { } func TestGetDB(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test in -short mode") + } clientL1 := simulated.NewBackend(nil, simulated.WithBlockGasLimit(10000000)) testDir := path.Join(t.TempDir(), "reorgdetectorTestGetDB.sqlite")