41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package jobs
 | |
| 
 | |
| import (
 | |
| 	"go-admin/config"
 | |
| 	helper "go-admin/utils/redishelper"
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/go-admin-team/go-admin-core/sdk"
 | |
| 	"gorm.io/driver/mysql"
 | |
| 	"gorm.io/gorm"
 | |
| )
 | |
| 
 | |
| func TestTransferJob(t *testing.T) {
 | |
| 	dsn := "root:123456@tcp(127.0.0.1:3306)/eth_transfer?charset=utf8mb4&parseTime=True&loc=Local&timeout=1000ms"
 | |
| 	db, _ := gorm.Open(mysql.Open(dsn), &gorm.Config{})
 | |
| 	sdk.Runtime.SetDb("default", db)
 | |
| 
 | |
| 	config.ExtConfig.ApiEndpoint = "https://stylish-cool-fire.ethereum-sepolia.quiknode.pro/17572db4c091accfa5dc6faa0c60a805e5173459"
 | |
| 	config.ExtConfig.ProxyUrl = "http://127.0.0.1:7890"
 | |
| 
 | |
| 	helper.InitDefaultRedis("http://127.0.0.1:6379", "", 15) // 初始化配置
 | |
| 
 | |
| 	job := TransferJob{}
 | |
| 
 | |
| 	job.Exec(nil)
 | |
| }
 | |
| 
 | |
| // 测试状态任务
 | |
| func TestTransferStatusJob(t *testing.T) {
 | |
| 	dsn := "root:123456@tcp(127.0.0.1:3306)/eth_transfer?charset=utf8mb4&parseTime=True&loc=Local&timeout=1000ms"
 | |
| 	db, _ := gorm.Open(mysql.Open(dsn), &gorm.Config{})
 | |
| 	sdk.Runtime.SetDb("default", db)
 | |
| 
 | |
| 	config.ExtConfig.ApiEndpoint = "https://stylish-cool-fire.ethereum-sepolia.quiknode.pro/17572db4c091accfa5dc6faa0c60a805e5173459"
 | |
| 	config.ExtConfig.ProxyUrl = "http://127.0.0.1:7890"
 | |
| 
 | |
| 	job := TransferStatusJob{}
 | |
| 
 | |
| 	job.Exec(nil)
 | |
| }
 |