Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Goshimmer_without_tipselection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COLLET Ismael
Goshimmer_without_tipselection
Commits
3baa2488
Unverified
Commit
3baa2488
authored
4 years ago
by
capossele
Browse files
Options
Downloads
Patches
Plain Diff
Add double spend test
parent
d10306ed
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/double-spend/double-spend.go
+60
-0
60 additions, 0 deletions
tools/double-spend/double-spend.go
with
60 additions
and
0 deletions
tools/double-spend/double-spend.go
0 → 100644
+
60
−
0
View file @
3baa2488
package
main
import
(
"fmt"
"net/http"
"time"
"github.com/iotaledger/goshimmer/client"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address/signaturescheme"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/wallet"
"github.com/mr-tron/base58"
)
func
main
()
{
client
:=
client
.
NewGoShimmerAPI
(
"http://ressims.iota.cafe:8080"
,
http
.
Client
{
Timeout
:
30
*
time
.
Second
})
// genesis wallet
genesisSeedBytes
,
err
:=
base58
.
Decode
(
"7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih"
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
const
genesisBalance
=
1000000000
genesisWallet
:=
wallet
.
New
(
genesisSeedBytes
)
genesisAddr
:=
genesisWallet
.
Seed
()
.
Address
(
0
)
genesisOutputID
:=
transaction
.
NewOutputID
(
genesisAddr
,
transaction
.
GenesisID
)
// issue transactions which spend the same genesis output in all partitions
conflictingTxs
:=
make
([]
*
transaction
.
Transaction
,
2
)
conflictingTxIDs
:=
make
([]
string
,
2
)
receiverWallets
:=
make
([]
*
wallet
.
Wallet
,
2
)
for
i
:=
range
conflictingTxs
{
// create a new receiver wallet for the given conflict
receiverWallet
:=
wallet
.
New
()
destAddr
:=
receiverWallet
.
Seed
()
.
Address
(
0
)
receiverWallets
[
i
]
=
receiverWallet
tx
:=
transaction
.
New
(
transaction
.
NewInputs
(
genesisOutputID
),
transaction
.
NewOutputs
(
map
[
address
.
Address
][]
*
balance
.
Balance
{
destAddr
:
{
{
Value
:
genesisBalance
,
Color
:
balance
.
ColorIOTA
},
},
}))
tx
=
tx
.
Sign
(
signaturescheme
.
ED25519
(
*
genesisWallet
.
Seed
()
.
KeyPair
(
0
)))
conflictingTxs
[
i
]
=
tx
// issue the transaction
txID
,
err
:=
client
.
SendTransaction
(
tx
.
Bytes
())
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
conflictingTxIDs
[
i
]
=
txID
fmt
.
Printf
(
"issued conflict transaction %s
\n
"
,
txID
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment