Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Truffle Test Tips and other
Search
nakajo2011
November 10, 2018
Programming
200
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Truffle Test Tips and other
nakajo2011
November 10, 2018
More Decks by nakajo2011
See All by nakajo2011
Plasma_Overview_gbec20180928.pdf
nakajo2011
0
95
What is Ethereum about tech layer
nakajo2011
0
410
The Ethereum design direction.
nakajo2011
0
94
Report of Devcon5 2019.10.17
nakajo2011
0
650
Compare of Libra and Ethereum
nakajo2011
1
470
What is Move language
nakajo2011
1
1.2k
blockchain-changing-and-issues
nakajo2011
4
590
Thinking Scalability from DEX
nakajo2011
0
120
Truffleの紹介_in_hicon2018.pdf
nakajo2011
3
330
Other Decks in Programming
See All in Programming
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
Claspは野良GASの夢をみるか
takter00
0
190
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
AI時代のUIはどこへ行く?その2!
yusukebe
21
7.2k
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
200
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
340
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.6k
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
170
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
680
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
180
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
190
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
520
Featured
See All Featured
Designing Powerful Visuals for Engaging Learning
tmiket
1
410
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
290
Java REST API Framework Comparison - PWX 2021
mraible
34
9.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
190
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
220
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
610
Site-Speed That Sticks
csswizardry
13
1.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Transcript
Copyright ©2018 chaintope, Inc. all rights reserved. hicon2018 Truffle Test
Tips 2018/11/10 chaintope, Inc Yukishige Nakajo
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. Step - 2
1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. Step - 3
1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. # Analysis result
for BatchOverFlowToken: ~~ snip ~~ ==== Integer Overflow ==== SWC ID: 101 Type: Warning Contract: BatchOverFlowToken Function name: batchTransfer(address[],uint256) PC address: 2599 -------------------- In file: BatchOverFlowToken.sol:20 uint256(cnt) * _value -------------------- 1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. Step - 4
1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. ・truffle embeded node
or ganache-cliの場合 2. Truffle Testの起動シーケンス
Copyright ©2018 chaintope, Inc. all rights reserved. ・ganache-cli以外のnode(like go-ethereum) 2.
Truffle Testの起動シーケンス
Copyright ©2018 chaintope, Inc. all rights reserved. Truffleではクリーンな環境を作成する https://truffleframework.com/docs/truffle/testing/testing-your-contracts#clean-room-environment 1.
ganache-cli使う時と、go-ethereumなどを使う時で動作 が異なるので注意 2. コンパイルが通らないとNG a. solidity編集中にちょっとテストを。。ができない 3. Migrationが通らないとNG a. migration fileを作っている場合は特に注意 2. Truffle Testの起動シーケンス
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Contract.new() • 新しくsmart
contractのインスタンスを生成する • つまりnetworkにdeployされる • 基本的にはこれを使って書く • new()するたびにcontract addressは変わるので注意 • deployに膨大なgasを使うContractの場合、gasが不足 するかもしれないので注意 • その場合はgasPrice=1とかにしちゃえばいい 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Contract.deployed() • 事前にmigrationでdeployされたSmart
Contractのイン スタンスが帰ってくる • truffle devの時は基本的に使えない • ganache-cliの時は自分でmigrationを事前にする必 要がある 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Contract.deployed() • あまり使ったことはない
• インスタンス取得にdeployする必要がないので高速 • でも前の状態を保持しているので注意が必要 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. 4. HowTo
Event Test
Copyright ©2018 chaintope, Inc. all rights reserved. • Contract.EventName()なメソッドでEventは定義されて いる
• 引数は順番に次の3つ • topics : indexedをつけたparameterを絞り込む • term: Eventをキャッチするblock範囲 • callback: Filterに関係するeventが発生した時に呼ば れる 4. HowTo Event Test
Copyright ©2018 chaintope, Inc. all rights reserved. • Eventが発生したかどうかは結構重要 •
Eventが余分に発生していないこともチェックする必要が あある 4. HowTo Event Test
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. 5. Dapp Projects
test statistic
Copyright ©2018 chaintope, Inc. all rights reserved. • Research 20
Dapps • Make test projects: 4 • Not have test projects: 9 • Not found repository: 7 Has Test Project is 30 % 5. Dapp Projects test statistic
Copyright ©2018 chaintope, Inc. all rights reserved. ちなみに・・・・ TheDAO has
test …... https://github.com/slockit/DAO/tree/develop/tests 5. Dapp Projects test statistic
Copyright ©2018 chaintope, Inc. all rights reserved. 長時間ありがとうございました! おわり