-
Notifications
You must be signed in to change notification settings - Fork 0
codebase 测试
返回首页 | GSL 项目归档文档
分析日期:2026-03-25
Testing across all four sub-projects is minimal to absent. No test files exist in any sub-project. The Java project has <skipTests>true</skipTests> set permanently in pom.xml. The Solidity project has a Foundry test configuration but no test files. The two Vue projects have no test runner configured at all.
Runner: Foundry (forge test)
- Config:
gsl-contracts/foundry.toml - Solidity version:
0.8.25 - Optimizer: enabled, 200 runs
Fuzz Testing Config:
[profile.default.fuzz]
runs = 10Fuzz runs set to 10 (very low — default is 256). Indicates fuzz config exists but is not actively maintained.
Run Commands:
forge test # Run all tests
forge test -vvvv # Verbose output
forge test --match-test testFunctionName # Run specific test
forge coverage # Coverage reportLocation: Tests would live in gsl-contracts/test/ (Foundry convention)
- No test files currently exist in this directory
Naming Convention (Foundry standard, to follow when adding tests):
- File:
MyContract.t.sol - Test contract:
MyContractTest - Test function:
test_functionNameortestFuzz_functionName
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "forge-std/Test.sol";
import {MyContract} from "../src/MyContract.sol";
contract MyContractTest is Test {
MyContract public myContract;
function setUp() public {
myContract = new MyContract();
myContract.initialize(address(1), address(this));
}
function test_initialize() public {
assertEq(address(myContract.owner()), address(this));
}
function testFuzz_stakeAmount(uint256 amount) public {
vm.assume(amount > 0 && amount < type(uint128).max);
// test logic
}
}forge-std/=lib/forge-std/src/
@openzeppelin/=lib/openzeppelin-contracts/
@openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/
// Impersonate an address
vm.prank(userAddress);
myContract.stake(amount);
// Set block timestamp
vm.warp(block.timestamp + 1 days);
// Set ETH balance
vm.deal(userAddress, 1 ether);
// Expect revert
vm.expectRevert("Error message");
myContract.failingFunction();
// Expect event
vm.expectEmit(true, true, false, true);
emit Stake(userAddress, amount);
myContract.stake(amount);-
APYStatistics.calculateDynamicAPY— complex math with lookup tables -
AbstractStakeMiningV2Upgradeablestake/claim/withdraw flows — core economic logic -
FOMO3D.play— game timing and win logic -
HiveSwapswap paths — multi-token swap routing - UUPS upgrade authorization —
_authorizeUpgrademust reject non-owner
Requirements: None enforced View coverage:
forge coverage --report lcovRunner: JUnit 4 (declared in pom.xml)
-
spring-boot-starter-testalso present (includes JUnit 5 + Mockito) - Config:
hive-gls-java/pom.xml
Critical Note: Tests are globally skipped:
<skipTests>true</skipTests>This means mvn package and mvn install never run tests. Tests must be run explicitly with mvn test -DskipTests=false.
Run Commands:
mvn test # Skipped by default (skipTests=true)
mvn test -DskipTests=false # Force run tests
mvn test -Dtest=MyTestClass # Run specific test classLocation: hive-gls-java/src/test/java/com/unknown/gsl/
- No test files currently exist
Naming (Spring Boot convention to follow):
- File:
[ClassName]Test.java - Package mirrors main source:
com.unknown.gsl.[layer]
@SpringBootTest
@RunWith(SpringRunner.class)
public class OrderServiceTest {
@Autowired
private OrderService orderService;
@MockBean
private OrderMapper orderMapper;
@Test
public void testProcessChainCreateOrder() {
// Arrange
AddressProductPay mockPay = new AddressProductPay();
mockPay.setStatus(ProductPayStatus.CONFIRM_SUCCESS.value);
// ...
// Act
orderService.processChainCreateOrder(mockPay);
// Assert
verify(orderMapper, times(1)).insertSelective(any(Order.class));
}
}Framework: Mockito (included via spring-boot-starter-test)
@MockBean
private CoinPayConfigService coinPayConfigService;
when(coinPayConfigService.lambdaQuery()
.eq(CoinPayConfig::getCoinSymbol, "HIVE")
.one())
.thenReturn(mockConfig);-
OrderServiceImpl.processChainCreateOrder— blockchain event decoding and order creation -
OrderServiceImpl.processOrderRelease— transactional state machine update -
AddressInfoServiceImpl— user hierarchy and investment tracking -
EventServiceJob.executeInternal— scheduled job isolation and Redis lock behavior - Admin controllers — input validation and pagination
Requirements: None enforced (skipTests=true prevents any baseline)
View coverage:
mvn jacoco:report # If jacoco plugin is addedStatus: No test framework configured
- No
jest.config.*,vitest.config.*, or equivalent file - No test dependencies in
gsl-web-admin/package.json - No test scripts in
package.json
Run Commands: None available
No test files exist anywhere in gsl-web-admin/src/.
Vitest is the natural choice given the Vite build setup:
npm install -D vitest @vue/test-utils happy-domAdd to package.json:
{
"scripts": {
"test": "vitest",
"test:coverage": "vitest --coverage"
}
}Expected file location: co-located or in src/__tests__/
-
src/utils/request.ts— HTTP interceptor logic (complex branching for auth flows) -
src/utils/formatTime.ts,src/utils/toolsValidate.ts— pure utility functions - Pinia stores in
src/stores/— state transitions and actions
Status: No test framework configured
- No test dependencies in
gsl-dapp/package.json - No test scripts in
package.json
Run Commands: None available
No test files exist anywhere in gsl-dapp/src/.
-
src/request/request.js— HTTP interceptor and error code handling -
src/utils/global.js— contract address config and chain switching logic -
src/stores/index.js— Pinia store actions
| Project | Framework | Tests Exist | CI Enforced |
|---|---|---|---|
gsl-contracts |
Foundry | No | No |
hive-gls-java |
JUnit 4 + Spring Boot Test | No | No (skipTests=true) |
gsl-web-admin |
None configured | No | No |
gsl-dapp |
None configured | No | No |
No project has any tests. All test infrastructure additions must be built from scratch. The Java project has the most critical gap given it handles on-chain financial event processing.
Testing analysis: 2026-03-25
返回首页 | GSL 项目归档文档 | 生成日期:2026-03-25