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
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
230
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
260
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
200
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
9
5.1k
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
140
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.3k
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
790
ふつうのFeature Flag実践入門
irof
7
3.9k
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.6k
Inside Stream API
skrb
1
720
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
2
680
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
120
Featured
See All Featured
Tell your own story through comics
letsgokoyo
1
950
Code Reviewing Like a Champion
maltzj
528
40k
Unsuck your backbone
ammeep
672
58k
Navigating Team Friction
lara
192
16k
Making Projects Easy
brettharned
120
6.7k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Done Done
chrislema
186
16k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
390
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
30 Presentation Tips
portentint
PRO
1
320
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
160
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. 長時間ありがとうございました! おわり