Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-common
Commits
70089c98
Commit
70089c98
authored
Aug 11, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update test_fruit_machine.go
parent
3307e57b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
39 deletions
+44
-39
test_fruit_machine.go
script/test_fruit_machine.go
+44
-39
No files found.
script/test_fruit_machine.go
View file @
70089c98
...
@@ -25,51 +25,56 @@ func main() {
...
@@ -25,51 +25,56 @@ func main() {
if
err
:=
mysql
.
TestDB
.
Model
(
model
.
User
{})
.
Where
(
"code in ?"
,
fruitUserCodes
)
.
Find
(
&
users
)
.
Error
;
err
!=
nil
{
if
err
:=
mysql
.
TestDB
.
Model
(
model
.
User
{})
.
Where
(
"code in ?"
,
fruitUserCodes
)
.
Find
(
&
users
)
.
Error
;
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
for
{
for
i
:=
0
;
i
<
10
;
i
++
{
times
:=
20
+
rand
.
Intn
(
30
)
go
func
()
{
for
i
:=
0
;
i
<
times
;
i
++
{
for
{
times
:=
20
+
rand
.
Intn
(
30
)
for
i
:=
0
;
i
<
times
;
i
++
{
arr
:=
[]
int
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
}
arr
:=
[]
int
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
}
rand
.
Shuffle
(
len
(
arr
),
func
(
i
,
j
int
)
{
rand
.
Shuffle
(
len
(
arr
),
func
(
i
,
j
int
)
{
arr
[
i
],
arr
[
j
]
=
arr
[
j
],
arr
[
i
]
arr
[
i
],
arr
[
j
]
=
arr
[
j
],
arr
[
i
]
})
})
for
_
,
id
:=
range
arr
{
for
_
,
id
:=
range
arr
{
if
rand
.
Intn
(
100
)
<
30
{
if
rand
.
Intn
(
100
)
<
30
{
break
break
}
}
url
:=
"https://test.apiv1.faceline.live/v1/fruitMachine/"
url
:=
"https://test.apiv1.faceline.live/v1/fruitMachine/"
method
:=
"POST"
method
:=
"POST"
amount
:=
fruitAmounts
[
rand
.
Intn
(
len
(
fruitAmounts
))]
amount
:=
fruitAmounts
[
rand
.
Intn
(
len
(
fruitAmounts
))]
payload
:=
strings
.
NewReader
(
fmt
.
Sprintf
(
"fruitId=%d&amount=%d"
,
id
,
amount
))
payload
:=
strings
.
NewReader
(
fmt
.
Sprintf
(
"fruitId=%d&amount=%d"
,
id
,
amount
))
client
:=
&
http
.
Client
{}
client
:=
&
http
.
Client
{}
req
,
err
:=
http
.
NewRequest
(
method
,
url
,
payload
)
req
,
err
:=
http
.
NewRequest
(
method
,
url
,
payload
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
return
return
}
}
u
:=
users
[
rand
.
Intn
(
len
(
users
))]
u
:=
users
[
rand
.
Intn
(
len
(
users
))]
token
,
_
:=
jwt
.
GenerateToken
(
u
.
Id
,
u
.
ExternalId
,
"hiloApi"
)
token
,
_
:=
jwt
.
GenerateToken
(
u
.
Id
,
u
.
ExternalId
,
"hiloApi"
)
req
.
Header
.
Add
(
"nonce"
,
"hilo"
)
req
.
Header
.
Add
(
"nonce"
,
"hilo"
)
req
.
Header
.
Add
(
"token"
,
token
)
req
.
Header
.
Add
(
"token"
,
token
)
req
.
Header
.
Add
(
"Content-Type"
,
"application/x-www-form-urlencoded"
)
req
.
Header
.
Add
(
"Content-Type"
,
"application/x-www-form-urlencoded"
)
res
,
err
:=
client
.
Do
(
req
)
res
,
err
:=
client
.
Do
(
req
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
return
return
}
}
defer
res
.
Body
.
Close
()
defer
res
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
res
.
Body
)
body
,
err
:=
ioutil
.
ReadAll
(
res
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
return
return
}
fmt
.
Printf
(
"body:%v,uid:%v
\n
"
,
string
(
body
),
u
.
Id
)
}
}
}
fmt
.
Println
(
string
(
body
)
)
//time.Sleep(time.Second * 55
)
}
}
}
}()
//time.Sleep(time.Second * 55)
}
}
time
.
Sleep
(
time
.
Hour
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment